ejgeske

ejgeske

Joined
Dec 05, 2008

Activity Stream

ejgeske commented on a Page, Building a Parent/Child Category Structure  -  Dec 05, 2008

on the say again, only the variable that was assigned with $this is assigned to the class for later use by all of the functions.

this is object oriented php which became available with php5

 Respond  
ejgeske commented on a Page, Building a Parent/Child Category Structure  -  Dec 05, 2008

in the following example, i will assign some variables that belong to a class. But are assigned inside one of the function/methods. If you only assign it as $example and not as $this->example, it does not assign that variable to the entire class, only in that method/function.

class myClass
{
var $example;
var $example2;

function say_what()
{
    $example = 'Hi';
    $this->example2 = 'Hi again';

    echo '$example: '.$example."<br/>";
    echo '$example2: '.$example2."<br/>";
    echo '$this->example: '.$this->example."<br/>";
    echo '$this->example2: '.$this->example2."<br/>";
}
function say_again()
{
    echo '$example: '.$example."<br/>";
    echo '$example2: '.$example2."<br/>";
    echo '$this->example: '.$this->example."<br/>";
    echo '$this->example2: '.$this->example2."<br/>";
}

}

$convo = new myClass();
$convo->say_what();
$convo->say_again();


PRINT OUT

// this is $convo->say_what();
$example: Hi
$example2: //blank
$this->example: //blank
$this->example2: Hi again

// this is $convo->say_again();
$example: //blank
$example2: //blank
$this->example: //blank
$this->example2: Hi again // only this one assigned to class shows.

 Respond  
ejgeske commented on a Page, Building a Parent/Child Category Structure  -  Dec 05, 2008

$this-> refers to the variables in the class ( "$this" means inside this or belongs to this object)

 Respond  
ejgeske commented on a Page, Building a Parent/Child Category Structure  -  Dec 05, 2008

It would be very helpful it you could add the database layouts.

Also, you only reference one database but you state we need to pull information from two.

In your class you state:
var $cat_id;
var $depth;
var $cat_title;
var $cat_parent_id;
var $cat_long_title;

It is hard to know which tables these belong to.
Also, in your $db->fetchrow(), is this a mysql_fetch_row, or mysql_fetch_object, assoc? Assuming you said row, im guessing it would be a fetch row, but clarification would be nice. Also, maybe a working script.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.