note 54058 added to function.mysql-query
| From: | javier dot alpizar at gmail dot com | Date: | Wed, 22 Jun 2005 15:30:37 +0000 |
| Subject: | note 54058 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90794@lists.php.net to get a copy of this message | ||
This is a function to return an associative or number indexed array. I hope this will help anyone,
saving a lot of lines ....
If the query was empty, returns false.
Note: always will return a array with one index, if the query result was only one row
<?
function exec_return_array($query,$mode=MYSQL_BOTH){
//Executes the query
$resource = mysql_query($query);
//Count the rows
if(mysql_num_rows($resource) > 0){
//'Resultset'
$result = array();
while ($row = mysql_fetch_array($resource,$mode)){
$result[] = $row;
}//end while
return $result;
}//end if
return false;
}//end function
?>
----
Manual Page -- http://www.php.net/manual/en/function.mysql-query.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54058
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54058&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54058&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54058&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54058&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54058&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54058&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54058&report=yes
Search -- http://master.php.net/manage/user-notes.php