Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.3

Bug #3607 Binding to null datasets causes fatal error
Submitted: 2005-02-26 16:20 UTC
From: nick at foobar dot org Assigned: asnagy
Status: Closed Package: Structures_DataGrid
PHP Version: 4.3.10 OS: FreeBSD
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 18 - 1 = ?

 
 [2005-02-26 16:20 UTC] nick at foobar dot org
Description: ------------ Using Structures::DataGrid 0.6.0 (and have tried 0.6.2) Reproduce code: --------------- <?php require_once 'Structures/DataGrid.php'; $res =& $peardb->query('SELECT * FROM blahtable WHERE 1=0'); while ($record = $res->fetchRow()) { $dataSet[] = $record; } $dg =& new Structures_DataGrid(20, 1); $dg->bind($dataSet); print $dg->renderer->toHTML(); ?> Expected result: ---------------- The code should fail gracefully with some form of recoverable error. Better still, there should be some way of specifying a callback for what should happen when a null data set is specified. Actual result: -------------- Fatal error: Call to a member function on a non-object in /usr/local/share/pear/Structures/DataGrid/DataSource/DataObject.php on line 206

Comments

 [2005-03-07 17:43 UTC] justinpatrin
I know what the problem is here (just ran into it myself). Look at _detectSourceType(). It switches on $source, then all of the cases are booleans. When the source equates to false (array(), etc) then the first entry matches (DB_DataObject). This should be "switch (true)", not "switch($source)".
 [2005-03-30 15:45 UTC] asnagy
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.