Subject Re: [firebird-php] Re: PDO
Author Jochem Maas
Alan McDonald wrote:
>>Ok got PHP_intebase working and am now working on generating a
>>html_TreeMenu from a database query.
>>
>>I'm using HTML_TreeMenu and loopping through my results but i keep
>>getting this message "Call to a member function addItem() on a
>>non-object". I have done hardly any OOP but I think the problem is
>>somewhere in the this code:

I assume the error is being reported with the line number of the line that
reads as:

" $$branch = &$$branch_parent->addItem( " ... <etc>

>>
>>while($row = ibase_fetch_object($result)) {
>> //print_r($Result);
>> echo $row->Name .'<br>';
>> echo 'Parent, '.$row->ParentId .'<br>';
>> echo $row->ID .'<br>';
>> // populate variables from db...
>> $branch=$row->ID;
>> $branch_parent = $row->ParentId;
>> $branch_value = $row->Name;
>> echo 'branch, '.$branch;
>> /*
>> $branch = $db->f("ID");
>> $branch_parent = $db->f("ParentId");
>> $branch_value = $db->f("Name");*/
>>
>> // Build tree...
>> if($branch_parent) {
>> $$branch_parent=$branch_parent;
>> $$branch = &$$branch_parent->addItem(new


what does var_dump($branch_parent, $$branch_parent) output?

what does $db->f() do? does it return a field name, a field object?
if its actually returning an object, what kind of object, and is this
object in any way compatible with the HTML_TreeNode and HTML_Tree classes?

>>HTML_TreeNode(array('text'
>>=> $branch, 'link' => $branch_value, 'icon' => $icon, 'expandedIcon'
>>=> $expandedIcon)));
>> } else {
>> $$branch = new HTML_TreeNode(array('text'
>>=> $branch, 'link' =>
>>$branch_value, 'icon' => $icon, 'expandedIcon' => $expandedIcon));
>> $tree[$i++] = &$$branch; // Indexed
>>reference for final tree
>>consruction.
>> }
>> //unset($branch);
>> //unset($branch_parent);
>> //unset($branch_value);
>>
>> //$Result = $db->next_record();
>> } //wend
>>
>>thanks for all the help, some time even the smallest comments just
>>seem to make things click.
>>Darren
>>
>
>
> why $$branch? - 2 $ signs

variable variables - not sure they are the best solution here
... although I have used var vars in similar tree buidling exercises.

figure out what the following code is doing and you should be
well on your way to grokking php var vars :-)

<?php

$var1 = "123"; $var2 = "var1";
echo $$var2, "\n", ${"var1"}, "\n", ${${"var2"}}, "\n";

?>

> Alan
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>