在Zend框架中,如何檢查zend_db_select
是否返回結果?如何檢查Zend select是否返回結果
$result = $this->fetchAll();
有沒有更好的辦法,而不是使用:
if(count($result) != 0){
//result found!
}
在Zend框架中,如何檢查zend_db_select
是否返回結果?如何檢查Zend select是否返回結果
$result = $this->fetchAll();
有沒有更好的辦法,而不是使用:
if(count($result) != 0){
//result found!
}
$rows = $this->fetchAll();
return (!empty($rows)) ? $rows : null;
我喜歡用經典:
//most of these queries return either an object (Rowset or Row) or FALSE
if (!$result){
//do some stuff
} else {
return $result;
}
方法返回NULL,而不是FALSE。使用if條件檢查此值。
你在這裏展示的方法有什麼問題? – 2012-02-23 07:43:41
我在找一個更好的方法。 – rjmcb 2013-07-03 07:23:19