Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Php Programming Code Examples

Php > Databases Code Examples

Function Query2Array will read an PEAR-DB-Query-Result into an Array

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Function Query2Array will read an PEAR-DB-Query-Result into an Array <?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; } ?>