<?php

dl('adodb.so');
include_once 'phplens/adodb/adodb.inc.php';
$db = ADONewConnection('mysql');
$server = 'jaguar';
$user = '******';
$password = $_GET['pwd'];
$database = 'northwind';
$db->Connect($server, $user, $pwd, $database);
$rs = $db->Execute('select productname,unitsinstock from products');
while (!$rs->EOF) {
    print_r($rs->fields);
    print HTML_BR;
    adodb_movenext($rs);
    ## ADODB extension function
}
$rs->Close();
echo '<hr/>';
$rs = $db->Execute("select productname, unitsinstock from products where productid < 5");
$arr = adodb_getall($rs);
## ADOdb extension function
echo '<pre>';
print_r($arr);
echo '</pre>';
Exemple #2
0
 /**
  * return recordset as a 2-dimensional array.
  *
  * @param [nRows]  is the number of rows to return. -1 means every row.
  *
  * @return an array indexed by the rows (0-based) from the recordset
  */
 function &GetArray($nRows = -1)
 {
     global $ADODB_EXTENSION;
     if ($ADODB_EXTENSION) {
         $results = adodb_getall($this, $nRows);
         return $results;
     }
     $results = array();
     $cnt = 0;
     while (!$this->EOF && $nRows != $cnt) {
         $results[] = $this->fields;
         $this->MoveNext();
         $cnt++;
     }
     return $results;
 }
 /**
  * return recordset as a 2-dimensional array.
  *
  * @param [nRows]  is the number of rows to return. -1 means every row.
  *
  * @return an array indexed by the rows (0-based) from the recordset
  */
 function GetArray($nRows = -1)
 {
     global $ADODB_EXTENSION;
     if ($ADODB_EXTENSION) {
         $results = adodb_getall($this, $nRows);
         return $results;
     }
     $results = array();
     $cnt = 0;
     while (!$this->EOF && $nRows != $cnt) {
         // $results[] = $this->fields;
         $rs = $this->fields;
         $keys = array_keys($rs);
         $new_rs = null;
         foreach ($keys as $key) {
             $new_rs[strtolower($key)] = $rs[$key];
         }
         $results[] = $new_rs;
         $this->MoveNext();
         $cnt++;
     }
     return $results;
 }