note 41547 added to ref.sqlite

From: Date: Wed, 14 Apr 2004 12:16:10 +0000
Subject: note 41547 added to ref.sqlite
Groups: php.notes 
Request: Send a blank email to php-notes+get-68107@lists.php.net to get a copy of this message
If you want to get the list of all the columns in a table (and associated information), PRAGMA is helpful (see http://sqlite.org/lang.html#pragma for details): if (!($db=@sqlite_open("delme.db",0666,$sqliteerror))) die("Can't open database"); @sqlite_query ($db, 'DROP TABLE foo;'); sqlite_query($db, "CREATE TABLE foo (bar INTEGER PRIMARY KEY, baz VARCHAR(5));"); $aTableStruct = sqlite_array_query($db, "PRAGMA table_info('foo');", SQLITE_ASSOC); for ($i=0,$aNames=array();$i<sizeof($aTableStruct);++$i) $aNames[]=$aTableStruct[$i]['name']; var_dump ($aNames); // => ['bar', 'baz'] Note also that if you want to use more than one database in the same connection using "ATTACH DATABASE ..." then you should supply the complete database filename. Csaba Gabor ---- Manual Page -- http://www.php.net/manual/en/ref.sqlite.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41547 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41547&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41547&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68107) next »