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

search for in the

sqlite_fetch_object> <sqlite_fetch_array
Last updated: Fri, 18 Jul 2008

view this page in

sqlite_fetch_column_types

SQLiteDatabase->fetchColumnTypes

(No version information available, might be only in CVS)

SQLiteDatabase->fetchColumnTypes — Obtiene una matriz con los tipos de las columnas de una tabla

Descripción

array sqlite_fetch_column_types ( string $nombre_tabla , resource $manejador_bd [, int $tipo_resultado ] )

Método que sigue el estilo orientado a objetos:

SQLiteDatabase
array fetchColumnTypes ( string $nombre_tabla [, int $tipo_resultado ] )

sqlite_fetch_column_types() devuelve una matriz con los tipos de las columnas de la tabla indicada por el parámetro nombre_tabla .

Lista de parámetros

nombre_tabla

El nombre de la tabla que se quiere consultar.

manejador_bd

El recurso que identifica la base de datos SQLite (y que es el que devuelve la función sqlite_open()). Este parámetro no se requiere cuando se emplea el método orientado a objetos.

tipo_resultado

El parámetro opcional result_type acepta una serie de constantes que controlan como se indexa la matriz devuelta. Si se emplea el valor SQLITE_ASSOC se devuelven solamente índices asociativos (esto es, los campos tienen nombre) mientras que el valor SQLITE_NUM hace que se devuelvan solamente índices numéricos (los campos se referencian por números ordinales). Por último, el valor SQLITE_BOTH hace que se devuelvan tanto los índices numéricos como los asociativos. El valor por defecto para esta función es SQLITE_ASSOC.

Valores retornados

Devuelve una matriz con los tipos de las columnas de la tabla o FALSE en caso de error.

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.

Registro de cambios

Versión Descripción
5.1.0 Se añade result_type

Ejemplos

Example #1 Ejemplo no orientado a objetos

<?php
$manejador_bd 
sqlite_open('mysqlitedb');
sqlite_query($db'CREATE TABLE prueba (nombre varchar(10), comentario text)');
$columnas sqlite_fetch_column_types('prueba'$manejador_bdSQLITE_ASSOC);

foreach (
$columnas as $columna => $tipo) {
    echo 
"Columna: $columna  Tipo: $tipo";
}
?>

Example #2 Ejemplo orientado a objetos

<?php
$manejador_bd 
= new SQLiteDatabase('mysqlitedb');
$manejador_bd->query('CREATE TABLE prueba (nombre varchar(10), comentario text)');
$columnas $manejador_bd->fetchColumnTypes('prueba'SQLITE_ASSOC);

foreach (
$columnas as $columna => $tipo) {
    echo 
"Columna: $columna  Tipo: $tipo";
}
?>

El resultado del ejemplo seria:

Columna: nombre  Type: VARCHAR
Columna: comentario  Type: TEXT



sqlite_fetch_object> <sqlite_fetch_array
Last updated: Fri, 18 Jul 2008
 
add a note add a note User Contributed Notes
sqlite_fetch_column_types
enthusiast
06-Mar-2005 05:19
If I (OO version) try to add the contant SQLITE_ASSOC, (exactly as listed in the above example) it generates the following error:

SQLiteDatabase::fetchColumnTypes() expects exactly 1 parameter, 2 given in C:\....

If I remove it completely, it returns the associative array I expected.
10-Jan-2005 12:01
The problem with the permanently locked database file when using this function still seems to exist in PHP 5.0.3 (tested on win32).

However, you can get all the information you need about the fields of a table by using this query:

PRAGMA table_info(name_of_your_table);
hugo_pl at users dot sourceforge dot net
18-Aug-2004 06:55
This function, and the OO version, is bugged in PHP <= 5.0.1, locking the database until you restart the webserver.

http://bugs.php.net/bug.php?id=29476

sqlite_fetch_object> <sqlite_fetch_array
Last updated: Fri, 18 Jul 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites