检查Doctrine结果是NULL还是空或没有任何记录

Rey*_*ier 1 doctrine symfony-1.4 doctrine-1.2

哪种方法可以检查Doctrine查询结果是空的还是没有值以便向用户显示消息?我有这个代码:

public function executeIndex(sfWebRequest $request) {
        $this->sdriving_emisors = Doctrine_Core::getTable('SdrivingEmisor')->createQuery('a')->execute();
}
Run Code Online (Sandbox Code Playgroud)

在我看来,我正在检查如下:

<?php if (!empty($sdriving_emisors)): ?>
  // show records
<?php else: ?>
  // show message
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

但是因为$sdriving_emisors总是有内容不起作用,所以有什么帮助吗?PS:我正在使用Symfony 1.4.20

gle*_*gui 5

execute()方法返回一个DoctrineCollection对象.你可以使用count().

public function count(  )
Run Code Online (Sandbox Code Playgroud)

获取此集合中的记录数

返回整数