Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts

    object oriented php help

    i'm new to object oriented php

    now I have a class

    and wihtin the class I want to call a function with the $id
    How do I call a function (that returns an array) and put it to an array.

    I tried
    $this->product= getM($this-->id);
    but it's not working?
    any suggestions as well for some good tutorial on this would be helpful.




    function getM($id)

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Can't you just do

    PHP Code:
    $this->variable = array(12345); 

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts
    well the function opens the db and pullls a recordset to the array it returns

    i'm having trouble calling the functions with the id

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You will have to post more code for us to help.

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,074
    Thanks
    11
    Thanked 98 Times in 96 Posts
    a function external to the class ..
    PHP Code:
    <?
    $this
    ->product=getM($this->id);
    ?>
    or a function within the class (a class method) ??
    <?
    $this
    ->product=$this->getM($this->id);
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •