sqlite_fetch_column_types

(PHP 5)

sqlite_fetch_column_types

(no version information, might be only in CVS)

SQLiteDatabase->fetchColumnTypes --  Restituisce una matrice con il formato delle colonne di una tabella

Descrizione

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

Versione ad oggetti (metodo):

class SQLiteDatabase {

array fetchColumnTypes ( string table_name [, int result_type] )

}

sqlite_fetch_column_types() rRestituisce una matrice con il tipo di dato delle colonne della tabella indicata da table_name.

Elenco dei parametri

table_name

Nome della tabella.

dbhandle

Risorsa SQLite Database restituita da sqlite_open () quando usato in modo procedurale. Questo parametro non è richiesto nel metodo ad oggetti.

result_type

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.

Valori restituiti

Restituisce una matrice con i tipi di dati delle colonne, oppure FALSE in caso di errore.

I nomi delle colonne restituiti da SQLITE_ASSOC e da SQLITE_BOTH saranno maiuscoli o minuscoli in base al valore del parametro di configurazione sqlite.assoc_case.

Esempi

Esempio 1. Esempio procedurale

<?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 
"Column: $column  Type: $type";
}
?>

Esempio 2. Esempio ad oggetti

<?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 
"Column: $column  Type: $type";
}
?>

Il precedente esempio visualizzerà:

Column: bar  Type: VARCHAR
Column: arf  Type: TEXT