Re: Tree - problem with the option "whereAddOn"
| From: | Jeroen Houben | Date: | Mon, 07 Jul 2003 14:13:24 +0000 |
| Subject: | Re: Tree - problem with the option "whereAddOn" | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6519@lists.php.net to get a copy of this message | ||
Hi,
Looks like you're using quotes. I think it'll work if you initialise your tree like this, it works for me:
$userID = 'user_id = '. $some_var_with_the_user_id;
$tree_options = array(
'table'=>$table, 'whereAddOn'=> $userID
)
$this->tree = Tree::setup( 'Memory_DBnested',$dsn, $tree_options);
HTH
Jeroen
Tobias.Nebel@swr.de wrote:
Hello all! i use the class Tree 0.2.4 with PHP 4.2.3. my problem: when i use the option whereAddOn to use more than one tree in a DB. but i become after the add of the first element every time errors error adding root element: SELECT * FROM myTree WHERE 'user_id = 2' AND id=14474 error adding root element: SELECT * FROM myTree WHERE 'user_id = 2' AND id=Object error adding root element: SELECT * FROM myTree WHERE 'user_id = 2' AND id=Object .... and so on every thing is ok when i use the class without the option. my code:$table = 'myTree'; $userID = "'user_id = ".$userID."'"; $this->tree = Tree::setup( 'Memory_DBnested',$dsn,array('table'=>$table, 'whereAddOn'=> $userID)); $this->tree->setup();$root = $this->makeArray('root', ''); $rootID = $this->tree->add($root); if (PEAR::isError($rootID)) { echo 'error adding root element: '.$rootID->getUserInfo(); }$childOfRoot = $this->makeArray('childOfRoot', ''); $childOfRootID = $this->tree->add($childOfRoot, $rootID); if (PEAR::isError($childOfRootID)) { echo 'error adding root element: '.$childOfRootID->getUserInfo(); }$childOfChild = $this->makeArray('childOfChild', ''); $childOfChildID = $this->tree->add($childOfChild, $childOfRootID); if (PEAR::isError($childOfChildID)) { echo 'error adding root element: '.$childOfChildID->getUserInfo(); }function makeArray ($s, $comment) {return $array = array( 'name'=>$s, 'comment'=>$comment);} thx tobias