views:

75

answers:

1

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 what 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?

A: 

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);
}
Brian Fisher
this function is in my data mapper object. (not sure if it's the best place, but it works). but IS NULL worked for me, so thanks!
Andrew