|
|
|
| Title : |
Function Query2Array will read an PEAR-DB-Query-Result into an Array.
You may specify a Column used as Array-Keys,
and you may specify the Number of Rows to skip at the beginning and the
Number to fetch (-1 = infinite). |
| Categories : |
Functions, PHP, Databases |
 Thomas Kunth |
| Date : |
Jan 14th 2002 |
| Grade : |
3 of 5 (graded 2 times) |
| Viewed : |
8168 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Thomas Kunth |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
<?php
// DB.php is part of PEAR.
// It should be installed with PHP by default.
// Also the Include-Path for PEAR should be set by default.
// Take a look at
// http://www-user.tu-chemnitz.de/~meal/php/peardoc/index.html
// http://pear.php.net/
// http://www.koehntopp.de/php/
require_once("DB.php");
function Query2Array ( $result, $keyColumn = NULL, $skipRows = 0, $fetchRows = -
1 ) {
$retval = array();
if ( $skipRows >= $result->numRows() ) $skipRows = 0;
for ( $i = 1; $i <= $skipRows; $i++) $result->fetchRow();
$Rows = $result->numRows() - $skipRows;
if ( $fetchRows >= 0) $Rows = Min($Rows, $fetchRows);
$fetchRows = $Rows;
for ($i = 0; $i < $fetchRows; $i++ ) {
$row = $result->fetchRow();
if ( is_string($keyColumn) ) $retval[$row[$keyColumn]] = $row;
else $retval[] = $row;
}
return $retval;
}
?>
|
|
| normalize fields and strings used in where (command's Sql) Categories : PHP, Databases, Oracle, Functions | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | Visits-tracking Categories : PHP, Databases, MySQL, Errors and Logging, Functions | | | Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases, PHP, mSQL, Databases | | | Add, Edit /Update & Delete all in one Contact Management Form Categories : PHP, MySQL, Databases, Beginner Guides | | | GroupIT Engine v1.00rc1
Categories : PHP, Content Management, MySQL, Databases | | | mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases | | | This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change Categories : PHP, Arrays, Cookies, MySQL, Databases | | | List people whose birthdays fall on the current Day and Month
Categories : Databases, Date Time, MySQL, PHP | | | AITSH Statistics Categories : Complete Programs, Databases, HTML and PHP, Sessions, PHP | | | Newbie Notes #4 - Trapping dumb MySQL query errors Categories : PHP, Databases, MySQL, Debugging, Beginner Guides | | | email new items in db Categories : PHP, Email, Databases, MySQL, Beginner Guides | | | complete, simple, working example of a login screen/system using php functions, cookies, and a mysql database for begginers. Categories : Authentication, Complete Programs, PHP, MySQL, Databases | | | This script will return all of the information in every table listed in $myarray, and will return lists of field names and information for each item, Categories : PHP, MS Access, Databases | | | Recordset Class like ADO Recordset (plus DataBase Splitting feature) using ODBC functions Categories : PHP Classes, ODBC, Databases, PHP | |
| |
| |
|