|
|
|
| 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 : |
4752 |
| 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 | | | Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases, PHP, mSQL, Databases | | | Visits-tracking Categories : PHP, Databases, MySQL, Errors and Logging, 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 | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Authorize Me! An authentication script. Categories : MySQL, Databases, Authentication, PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Tropicalm Genetree Family (MySQL based family tree) Categories : PHP, Interfaces, Databases, MySQL, Complete Programs | | | mysql_escape_string Categories : PHP, MySQL, Databases, Strings | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | Email a user with out exposing email address Categories : PHP, Databases, MySQL, Email | |
|
|
|