note 41547 deleted from ref.sqlite by cmb

From: Date: Mon, 02 Nov 2020 14:56:49 +0000
Subject: note 41547 deleted from ref.sqlite by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215704@lists.php.net to get a copy of this message
Note Submitter: csaba at alum dot mit dot edu ---- 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

« previous php.notes (#215704) next »