note 63606 added to function.mysql-fetch-array

From: Date: Sat, 25 Mar 2006 06:25:11 +0000
Subject: note 63606 added to function.mysql-fetch-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-106563@lists.php.net to get a copy of this message
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; } ?> ---- Server IP: 61.195.146.164 Probable Submitter: 220.58.70.54 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php Edit -- http://master.php.net/note/edit/63606 Del: integrated -- http://master.php.net/note/delete/63606/integrated Del: useless -- http://master.php.net/note/delete/63606/useless Del: bad code -- http://master.php.net/note/delete/63606/bad+code Del: spam -- http://master.php.net/note/delete/63606/spam Del: non-english -- http://master.php.net/note/delete/63606/non-english Del: in docs -- http://master.php.net/note/delete/63606/in+docs Del: other reasons-- http://master.php.net/note/delete/63606 Reject -- http://master.php.net/note/reject/63606 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106563) next »