PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #1317

tableInfo for SQLite (includes fix)

Details

Request #1317tableInfo for SQLite (includes fix)
Submitted2004-04-30 03:24 UTC
Fromxiangweizhuo at hotmail dot com
Assigneddanielc
StatusClosed
PackageDB
PHP Version4.2.0
OSWindows
Roadmaps(Not assigned)

Comments

[2004-04-30 03:24 UTC] xiangweizhuo at hotmail dot com

Description:
------------
Need some table info from the SQLite database in sqlite.php

possible solution

function tableInfo($table, $mode = null)
{

$tableStruct = sqlite_array_query(
$this->connection, "PRAGMA table_info('$table');",
SQLITE_ASSOC);

for($i = 0; $i < count($tableStruct); $i++)
{
$tableStruct[$i]['flags'] = '';
$tableStruct[$i]['len'] = '';

//primary key
if($tableStruct[$i]['pk'] == 1)
{
$tableStruct[$i]['flags'] .= 'primary_key,';

//integer primary key, it will auto increment
if($tableStruct[$i]['type'] == 'INTEGER')
$tableStruct[$i]['flags'] .= 'auto_increment,';
}
}
//var_dump($tableStruct);
return $tableStruct;
}