PHP Doku:: Fetches a result row as an associative or numerically indexed array or both - sqlite3result.fetcharray.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenSQLite3Die SQLite3Result KlasseSQLite3Result::fetchArray

Ein Service von Reinhard Neidl - Webprogrammierung.

Die SQLite3Result Klasse

<<SQLite3Result::columnType

SQLite3Result::finalize>>

SQLite3Result::fetchArray

(PHP 5 >= 5.3.0)

SQLite3Result::fetchArray Fetches a result row as an associative or numerically indexed array or both

Beschreibung

public array SQLite3Result::fetchArray ([ int $mode = SQLITE3_BOTH ] )

Fetches a result row as an associative or numerically indexed array or both. By default, fetches as both.

Parameter-Liste

mode

Controls how the next row will be returned to the caller. This value must be one of either SQLITE3_ASSOC, SQLITE3_NUM, or SQLITE3_BOTH.

  • SQLITE3_ASSOC: returns an array indexed by column name as returned in the corresponding result set

  • SQLITE3_NUM: returns an array indexed by column number as returned in the corresponding result set, starting at column 0

  • SQLITE3_BOTH: returns an array indexed by both column name and number as returned in the corresponding result set, starting at column 0

Rückgabewerte

Returns a result row as an associatively or numerically indexed array or both.


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
alan at synergymx dot com
15.09.2010 1:56
To loop through a record set:

<?php
        $db
= new SQLite3('auth.sqlite');

       
$sql = "SELECT user_id, username, opt_status FROM tbl_user";

       
$result = $db->query($sql);//->fetchArray(SQLITE3_ASSOC);

       
$row = array();

       
$i = 0;

         while(
$res = $result->fetchArray(SQLITE3_ASSOC)){

             if(!isset(
$res['user_id'])) continue;

             
$row[$i]['user_id'] = $res['user_id'];
             
$row[$i]['username'] = $res['username'];
             
$row[$i]['opt_status'] = $res['opt_status'];

             
$i++;

          }

         
print_r($row);
?>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)