RE: [PEAR] Tree: Memory_DBSimple sample warnings/errors
| From: | Joseph Blythe | Date: | Thu, 01 May 2003 07:36:51 +0000 |
| Subject: | RE: [PEAR] Tree: Memory_DBSimple sample warnings/errors | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5153@lists.php.net to get a copy of this message | ||
Daniel,
Try something like this of the $options array must match your database
table;
$dsn = $dbtype . "://" . $dbuser . ":" . $dbpass . "@" . $dbhost .
"/" .
$dbname;
$options = array('table' => 'myTree',
'order' => 'name',
'columnNameMaps' => array('parentId' => 'parent',
'name' => 'name'));
$tree = Tree::setupMemory('DBsimple', $dsn, $options);
if not you can always tryout Richard Heyes Tree class explained here:
http://www.phpkitchen.com/article.php?story=20030227061009685
Hope this helps,
Regards,
Joseph
-----Original Message-----
From: daniel.garcia@assertio.es [mailto:daniel.garcia@assertio.es]
Sent: Thursday, 1 May 2003 4:44 PM
To: pear-general@lists.php.net
Subject: RE: [PEAR] Tree: Memory_DBSimple sample warnings/errors
Hi Joseph,
After a test, it works in my code
$menu = Tree::setupMemory( 'DBsimple',
$this->dsn_local,
$opciones_tree);
$menu->setup();
if ($menu->hasChildren(10)) echo " --> Has children";
else echo " --> No children";
It's probably something with the sample, or more probably with the options
I used....
Regards,
-- Daniel
"Joseph Blythe" <joseph@optcom.net.au>
01/05/2003 08:19
Para: <daniel.garcia@assertio.es>
cc: "Pear-General \(E-mail\)" <pear-general@lists.php.net>
Asunto: RE: [PEAR] Tree: Memory_DBSimple sample warnings/errors
Daniel,
I believe that that the function haschildren() should be: hasChildren() as
I
was using that method today you might want to look into that ?
Regards,
Joseph
-----Original Message-----
From: daniel.garcia@assertio.es [mailto:daniel.garcia@assertio.es]
Sent: Thursday, 1 May 2003 2:20 PM
To: pear-general@lists.php.net
Subject: [PEAR] Tree: Memory_DBSimple sample warnings/errors
Hi,
I get errors when I run the Memory_DBSimple.php example:
Warning: Invalid argument supplied for foreach() in
c:\php\pear\Tree\Memory.php on line 1283
I tried downloading the CVS version of Memory.php, but got the same
results. I got rid of these warnings modifying the code as follows:
// if $node is an array, we assume it is a collection of elements
if( !is_array($node) )
$nodes = $this->getNode($node); // if $node==0 then the entire
tree is retreived
else $nodes = $node;
(added the else $nodes = $node line on line 1271). I hope I'm not breaking
anything.
The example runs then nicely dumping the info until a fatal error arises:
Fatal error: Call to undefined function: haschildren() in
c:\php\pear\Tree\Memory\DBsimple.php on line 221
When I try to upgrade the package, it says I'm ok:
C:\WINNT\system32>pear upgrade tree
downloading Tree-0.2.4.tgz ...
...done: 48,824 bytes
upgrade to a newer version (0.2.4 is not newer than 0.2.4)
Please advise...
-- Daniel