I have an SQLite database, eventually will be a MySQL database and I'm using Zend Framework. I'm trying to fetch all the rows in a table where the 'date_accepted'
column is empty/null/doesn't have a value. This is wha开发者_开发百科t I have so far:
public function fetchAllPending()
{
$select = $this->getDbTable()->select();
$select->where('date_accepted = ?', 'null');
return $this->fetchAll($select);
}
What am I doing wrong? How would you write this in plain SQL, and/or using Zend_Db_Select
?
Two possible issues I see. What is the function getDbTable? If your class inherits from Zend_Db_Table that function shouldn't be necessary. Second maybe you should try IS NULL instead of = null with quoting null into the query.
public function fetchAllPending()
{
$select = $this->select()->where('date_accepted IS NULL');
return $this->fetchAll($select);
}
精彩评论