The execute() method returns an DoctrineCollection Object. You can use count().
public function count( )
Gets the number of records in this collection
Returns integer
Frage
Which is the right way to check if Doctrine query result is empty or hasn't values in order to show a message to users? I've this code:
public function executeIndex(sfWebRequest $request) {
$this->sdriving_emisors = Doctrine_Core::getTable('SdrivingEmisor')->createQuery('a')->execute();
}
And in my view I'm checking as follow:
<?php if (!empty($sdriving_emisors)): ?>
// show records
<?php else: ?>
// show message
<?php endif; ?>
But doesn't work because $sdriving_emisors
always has content, so any help?
PS: I'm working with Symfony 1.4.20
Lösung
The execute() method returns an DoctrineCollection Object. You can use count().
public function count( )
Gets the number of records in this collection
Returns integer