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

search for in the

sqlite_fetch_object> <sqlite_fetch_array
Last updated: Fri, 14 Aug 2009

view this page in

sqlite_fetch_column_types

SQLiteDatabase->fetchColumnTypes

(PHP 5)

sqlite_fetch_column_types -- SQLiteDatabase->fetchColumnTypes Retourne un tableau des types de colonnes d'une certaine table

Description

array sqlite_fetch_column_types ( string $table_name , resource $dbhandle [, int $result_type ] )

Style orienté objet

SQLiteDatabase
array fetchColumnTypes ( string $table_name [, int $result_type ] )

sqlite_fetch_column_types() retourne un tableau de types de colonnes depuis la table table_name spécifiée.

Liste de paramètres

table_name

Le nom de la table à interroger.

dbhandle

La ressource de base de données SQLite; retournée par sqlite_open() lorsqu'utilisée de manière procédurale. Ce paramètre n'est pas requis si vous utilisez la méthode orientée objet.

result_type

Le paramètre optionnel result_type accepte une constante et détermine comment le tableau retourné doit être indexé. L'utilisation de SQLITE_ASSOC retournera uniquement un tableau associatif (nom des champs) tandis que SQLITE_NUM retournera un tableau indexé numériquement (numéro ordinal des champs). SQLITE_BOTH retournera des indices numériques et associatifs. SQLITE_ASSOC est la valeur par défaut pour cette fonction.

Valeurs de retour

Retourne un tableau des types de données des colonnes; FALSE en cas d'erreur.

Les noms de colonnes retournés par SQLITE_ASSOC et SQLITE_BOTH suivent les règles concernant la case définie par l'option de configuration sqlite.assoc_case.

Historique

Version Description
5.1.0 Ajout de result_type

Exemples

Exemple #1 Style procédural

<?php
$db 
sqlite_open('mysqlitedb');
sqlite_query($db'CREATE TABLE foo (bar varchar(10), arf text)');
$cols sqlite_fetch_column_types('foo'$dbSQLITE_ASSOC);

foreach (
$cols as $column => $type) {
    echo 
"Colonne : $column  Type : $type";
}
?>

Exemple #2 Style orienté objet

<?php
$db 
= new SQLiteDatabase('mysqlitedb');
$db->query('CREATE TABLE foo (bar varchar(10), arf text)');
$cols $db->fetchColumnTypes('foo'SQLITE_ASSOC);

foreach (
$cols as $column => $type) {
    echo 
"Colonne : $column  Type : $type";
}
?>

L'exemple ci-dessus va afficher :

Colonne : bar  Type : VARCHAR
Colonne : arf  Type : TEXT



sqlite_fetch_object> <sqlite_fetch_array
Last updated: Fri, 14 Aug 2009
 
add a note add a note User Contributed Notes
sqlite_fetch_column_types
enthusiast
06-Mar-2005 04: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 11: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 04: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, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites