ORDER BY not working with Zend_Db_Table and Zend_Db_Table_Select and SQLite

View: New views
1 Messages — Rating Filter:   Alert me  

ORDER BY not working with Zend_Db_Table and Zend_Db_Table_Select and SQLite

by Joshua Beall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I'm using SQLite for a small app I put together to track commuting I do with my coworkers.

I'm trying to order the database results I got back.  Here's what I've done:

                // Now get a record of the commutes that have taken place
                $orderClause = ($commuteModel->select()->order("date DESC"));
                $commutes = $commuteModel->fetchAll($orderClause);

However, this throws the exception:

Fatal error:  Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[HY000]: General error: 14 unable to open database file' in D:\dev\phpdev\CarpoolTracker\library\Zend\Db\Statement\Pdo.php:238
Stack trace:
#0 D:\dev\phpdev\CarpoolTracker\library\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 D:\dev\phpdev\CarpoolTracker\library\Zend\Db\Adapter\Abstract.php(405): Zend_Db_Statement->execute(Array)
#2 D:\dev\phpdev\CarpoolTracker\library\Zend\Db\Adapter\Pdo\Abstract.php(205): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array)
#3 D:\dev\phpdev\CarpoolTracker\library\Zend\Db\Table\Abstract.php(1184): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select))
#4 D:\dev\phpdev\CarpoolTracker\library\Zend\Db\Table\Abstract.php(1039): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select))
#5 D:\dev\phpdev\CarpoolTracker\application\default\controllers\IndexController.php(57): Zend_Db_Table_Abstract->fetchAll(Object(Zend_Db_Table_Select))
#6 D:\dev\phpdev\Carpo in D:\dev\phpdev\CarpoolTracker\library\Zend\Db\Statement\Pdo.php on line 238

I also tried:

                // Now get a record of the commutes that have taken place
                $orderClause = ($commuteModel->select()->order("date DESC"));
                $commutes = $commuteModel->fetchAll(null,"date DESC");

But I get the same exception.

If I just do a fetchAll() without any parameters, it works fine--except that the order of the results is not what I want.

It seems as if somehow the DB is getting locked by the Zend_Db_Table_Select object, and then the Zend_Db_Table object can't access it?  What should I do?