downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SQLite3Result::finalize> <SQLite3Result::columnType
[edit] Last updated: Fri, 25 May 2012

view this page in

SQLite3Result::fetchArray

(PHP 5 >= 5.3.0)

SQLite3Result::fetchArray 結果の行を、連想配列あるいは数値添字配列あるいはその両方で取得する

説明

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

結果の行を、連想配列あるいは数値添字配列あるいはその両方で取得します。 デフォルトでは両方で取得します。

パラメータ

mode

次の行をどのように返すかを制御します。値は SQLITE3_ASSOCSQLITE3_NUMSQLITE3_BOTH のいずれかでなければなりません。

  • SQLITE3_ASSOC: 返された結果セットのカラム名をインデックスとする配列を返します。

  • SQLITE3_NUM: 返された結果セットのカラム番号をインデックスとする配列を返します。 カラム番号は 0 から始まります。

  • SQLITE3_BOTH: 返された結果セットのカラム名とカラム番号の両方をインデックスとする配列を返します。 カラム番号は 0 から始まります。

返り値

結果の行を、連想配列あるいは数値添字配列あるいはその両方で取得します。 行がない場合は FALSE を返します。



add a note add a note User Contributed Notes SQLite3Result::fetchArray
alan at synergymx dot com 14-Sep-2010 04: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);
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites