ZF-9266: Check if Zend_Db_Select is in an empty state


Sometimes I need to know if a select instance is in an empty state (just initialized or fully resetted).

Since the select class is hardcoded in the Adapters, I can't implement this method for myself, so I need to do this check:

$select = Zend_Db_Table::getDefaultAdapter()->select();


$selectString = $select->__toString();
if (empty($selectString)) {
    // empty state

My proposal is for a method {{isEmpty()}} (or any better name), that could do this check, maybe comparing the {{$_parts}} and {{$_partsInit}} properties.

public function isEmpty()
    return self::$_partsInit === $this->_parts;


No comments to display