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 11:20 UTC Modified: 2006-12-26 22:34 UTC
From: nick at foobar dot org Assigned: asnagy
Status: Closed Package: Structures_DataGrid
PHP Version: 4.3.10 OS: FreeBSD
Roadmaps: (Not assigned)    

 [2005-02-26 11: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


 [2005-03-07 12: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 09: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 In case this was a 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.