note 63606 deleted from function.mysql-fetch-array by bjori

From: Date: Sat, 25 Mar 2006 10:51:31 +0000
Subject: note 63606 deleted from function.mysql-fetch-array by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106573@lists.php.net to get a copy of this message
Note Submitter: kerosuppi Reason: bad code ---- Some handy utility function. (It works like the function in DB of PEAR) <?php //get the first result from mysql function getOne($query, $link = NULL) { if ($link == NULL) $result = mysql_query($query); else $result = mysql_query($query, $link); if ($result) { if (false !== ($array = mysql_fetch_row($result))) return $array[0]; return NULL; } return false; } //get the first row from mysql function getRow($query, $link = NULL) { if ($link == NULL) $result = mysql_query($query); else $result = mysql_query($query, $link); if ($result) { if (false !== ($array = mysql_fetch_assoc($result))) return $array; return array(); } return false; } //get the first column from mysql function getColumn($query, $link = NULL) { if ($link == NULL) $result = mysql_query($query); else $result = mysql_query($query, $link); $column = array(); if ($result) { while (false !== ($array = mysql_fetch_row($result))) $column[] = $array[0]; } else return false; return $column; } ?>

« previous php.notes (#106573) next »