note 31768 added to function.mysql-num-rows

From: Date: Fri, 02 May 2003 22:05:42 +0000
Subject: note 31768 added to function.mysql-num-rows
Groups: php.notes 
Request: Send a blank email to php-notes+get-47406@lists.php.net to get a copy of this message
It seems that mysql_num_rows actually returns NULL (at least that's what gettype() shows me) if there are no rows. I've seen countless instances where in a MySQL class or function someone has gone through (what seems to me) reduntant statements to return false if there are no rows. I.E. // Class function function rows() { $rows = mysql_num_rows($this->querid); if ($rows == 0) { return false; } else { return $rows; } When they could simply write: // Class function function rows() { return mysql_num_rows($this->querid); } Of course, I may be wrong... -- http://www.php.net/manual/en/function.mysql-num-rows.php http://master.php.net/manage/user-notes.php?action=edit+31768 http://master.php.net/manage/user-notes.php?action=delete+31768 http://master.php.net/manage/user-notes.php?action=reject+31768

« previous php.notes (#47406) next »