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

search for in the

sqlite_fetch_array> <sqlite_factory
Last updated: Fri, 22 Aug 2008

view this page in

sqlite_fetch_all

SQLiteResult->fetchAll

SQLiteUnbuffered->fetchAll

(PHP 5, PECL sqlite:1.0-1.0.3)

sqlite_fetch_all -- SQLiteResult->fetchAll -- SQLiteUnbuffered->fetchAllObtiene todas las filas del resultado en forma de matriz de matrices

Descripción

array sqlite_fetch_all ( resource $manejador_resultado [, int $tipo_resultado [, bool $decodificar_binario ]] )

Método que sigue el estilo orientado a objetos:

SQLiteResult
array fetchAll ([ int $tipo_resultado [, bool $decodificar_binario ]] )
SQLiteUnbuffered
array fetchAll ([ int $tipo_resultado [, bool $decodificar_binario ]] )

sqlite_fetch_all() devuelve una matriz que contiene todos los valores del resultado representado por el parámetro manejador_resultado . Su funcionamiento es similar a emplear la función sqlite_query() (o sqlite_unbuffered_query()) y después llamar a sqlite_fetch_array() para cada una de las filas del resultado.

Lista de parámetros

manejador_resultado

El identificador del resultado de SQLite. Este parámetro no es obligatorio cuando se emplea el método orientado a objetos.

tipo_resultado

The optional result_type parameter accepts a constant and determines how the returned array will be indexed. Using SQLITE_ASSOC will return only associative indices (named fields) while SQLITE_NUM will return only numerical indices (ordinal field numbers). SQLITE_BOTH will return both associative and numerical indices. SQLITE_BOTH is the default for this function.

decodificar_binario

When the decode_binary parameter is set to TRUE (the default), PHP will decode the binary encoding it applied to the data if it was encoded using the sqlite_escape_string(). You should normally leave this value at its default, unless you are interoperating with databases created by other sqlite capable applications.

Valores retornados

Devuelve una matriz que contiene las filas restantes del resultado. Si se llama a la función justo después de sqlite_query(), devuelve todas las filas. Si se llama después de la función sqlite_fetch_array(), devuelve el resto. Si el resultado no contiene filas, devuelve una matriz vacía.

The column names returned by SQLITE_ASSOC and SQLITE_BOTH will be case-folded according to the value of the sqlite.assoc_case configuration option.

Ejemplos

Example #1 Ejemplo no orientado a objetos

<?php
$manejador_bd 
sqlite_open('sqlitedb');
$consulta sqlite_query($manejador_bd'SELECT nombre, email FROM usuarios LIMIT 25');
$resultado sqlite_fetch_all($consultaSQLITE_ASSOC);
foreach (
$resultado as $fila) {
    echo 
'Nombre: ' $fila['nombre'] . '  E-mail: ' $fila['email'];
}
?>

Example #2 Ejemplo orientado a objetos

<?php
$manejador_bd 
= new SQLiteDatabase('sqlitedb');

$consulta $manejador_bd->query('SELECT nombre, email FROM usuarios LIMIT 25'); // resultado almacenado (buffered)
$consulta $manejador_bd->unbufferedQuery('SELECT nombre, email FROM usuarios LIMIT 25'); // resultado no almacenado (unbuffered)

$resultado $consulta->fetchAll(SQLITE_ASSOC);
foreach (
$resultado as $fila) {
    echo 
'Nombre: ' $fila['nombre'] . '  E-mail: ' $fila['email'];
}
?>

Ver también



add a note add a note User Contributed Notes
sqlite_fetch_all
Minots Estichá <minots at D0X dot de>
21-Oct-2004 06:15
The usage of sqlite_fetch_all should be your choise
(instead the well known practice of "while()" loop)
when unmodified tabledata is prefered.

Example code for a better illustration:
<?php
if ($dbhandle = sqlite_open('mysqlitedb', 0666, $sqliteerror)):
  
$query  = "SELECT x, y FROM sometable LIMIT 3;";
  
$result = sqlite_query($dbhandle, $query);

  
// usage with sqlite_fetch_all
  
$array1 = sqlite_fetch_all($result, SQLITE_ASSOC);

  
// the "well known practice"
  
$i = '0';
   while (
$row = sqlite_fetch_array($result, SQLITE_ASSOC)):
      
$array2["$i"] = $row;
      
$i++;
   endwhile;

  
sqlite_close($dbhandle);
endif;
?>

There are no differents within the values of array1 and array2.
Both arrays will be something like:

Array
(
    [0] => Array
        (
            [x] => 22004
            [y] => example_data1
        )

    [1] => Array
        (
            [x] => 92044
            [y] => example_data2
        )

    [2] => Array
        (
            [x] => 143060
            [y] => example_data3
        )
)

If you want to let me know about your comments, feel
free to send me a note via feedback-formular at:
http://www.d0x.de/pages/kontakt.php

sqlite_fetch_array> <sqlite_factory
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites