“IS NULL” in Zend_Db_Table select not working

最后都变了- 提交于 2019-12-04 06:40:35

The solution was to be found in Machine's comment on my original post. Doing what he suggested I noticed that Zend created an inner join as I was using the wrong select method, so:

$select = $this->getDbTable()->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
        ->setIntegrityCheck(false)
        ->joinLeft('images', 'images.oldFilename =
                                               availablePictures.filename')
               ->where('images.ref IS NOT NULL');
$resultSet = $this->getDbTable()->fetchAll( $select );

is how it should be.

My thinking is it has to do with the way MySql decides what is NULL and what isn't. Is it possible that the results you are expecting have a default assignment of the empty string '' or 0 in the images.ref column? MySql does not treat those as NULLs. Have a look here:

http://dev.mysql.com/doc/refman/4.1/en/working-with-null.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!