2009年5月2日星期六

Re: [fw-db] How to know if find() or fetchRow() got any row?

You can get the row count in two ways:

$rows = $table->fetchAll();
$count = count($rows);
$count = $rows->count();

For find(), I usually only expect one row (for single-column primary keys) so I usually code it like this:

$row = $table->find(123)->current();
if (null === $row) {
    // no row found, throw exception
}

// do something with row

-Hector


On Sat, May 2, 2009 at 10:37 PM, iceangel89 <comet2005@gmail.com> wrote:

how can i find out if find() or fetchRow() got any rows?
--
View this message in context: http://www.nabble.com/How-to-know-if-find%28%29-or-fetchRow%28%29-got-any-row--tp23352827p23352827.html
Sent from the Zend DB mailing list archive at Nabble.com.


没有评论: