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?

Andrew
  • 227,796
  • 193
  • 515
  • 708

1 Answers1

1

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
  • 23,519
  • 15
  • 78
  • 82
  • 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 Oct 30 '09 at 00:52
  • While using Zend 2.4.7's TableGateway, I found the following helpful http://stackoverflow.com/a/32238396/3112527 . – m1st0 Aug 26 '15 at 23:40