Re: Tree - problem with the option "whereAddOn"
| From: | Tobias dot Nebel at swr dot de | Date: | Mon, 07 Jul 2003 14:51:35 +0000 |
| Subject: | Re: Tree - problem with the option "whereAddOn" | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-6520@lists.php.net to get a copy of this message | ||
Hello again,
sorry, this change nothing. the same errors again.
but thx
Tobias
Jeroen Houben <jeroen@terena.nl> am 07.07.2003 16:13:24
An: Tobias.Nebel@swr.de
Kopie: pear-general@lists.php.net
Fax:
Thema: Re: [PEAR] Tree - problem with the option "whereAddOn"
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
>
>
>
>
>
>
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php