[Fwd: Re: [PEAR] Tree - problem with the option "whereAddOn"]

From: Date: Mon, 07 Jul 2003 14:51:56 +0000
Subject: [Fwd: Re: [PEAR] Tree - problem with the option "whereAddOn"]
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-6521@lists.php.net to get a copy of this message
-------- Original Message -------- Subject: Re: [PEAR] Tree - problem with the option "whereAddOn" Date: Mon, 07 Jul 2003 16:51:23 +0200 From: Jeroen Houben <jeroen@terena.nl> To: Tobias.Nebel@swr.de References: <OFF818048F.6FACAAB8-ONC1256D5C.00518C17@SWR.DE> Hmm, well the following options works for me:
      $whereAddOn = 'user_id='.$user_id;
      $whereAddOn .= " AND permission='$perm'";
          $options = array(
      'table'                =>'vw_sectiontree',
      'whereAddOn'        =>$whereAddOn,
      'order'                =>'displayorder',
      'columnNameMaps'    =>
          array(
          'id'            =>'section_id',
          'parentId'         =>'parent_id'
          )
      );
I'm using this with postgresql, but it also works with MySql. I'm not sure why the last two of your queries use "id=Object", you must be passing an object there instead of an object property or an integer. Jeroen Tobias.Nebel@swr.de wrote:
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


« previous php.pear.general (#6521) next »