note 45078 deleted from function.sqlite-query by tomsommer

From: Date: Wed, 25 Aug 2004 21:37:28 +0000
Subject: note 45078 deleted from function.sqlite-query by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75260@lists.php.net to get a copy of this message
Note Submitter: webmaster at php5info dot com ---- I found an easier way to insert multiples queries with sqlite_query. Less code is better :) First, you need to store your SQL queries. Do not forget to seperate each query with ";". One query = one line $db = sqlite_open('resahotel', 0666, $sqliteerror); // resahotel is the db name created or accessed $sql = "CREATE TABLE CLIENT (ID INTEGER NOT NULL PRIMARY KEY, NOM VARCHAR(50), ADRESSE_RUE VARCHAR(100), ADRESSE_CP INTEGER, ADRESSE_VILLE VARCHAR(30), PAYS VARCHAR(30)); INSERT INTO CLIENT (NOM, ADRESSE_RUE, ADRESSE_CP, ADRESSE_VILLE, PAYS) VALUES ('DURAND', '48 rue de l Elysée', '38000','Grenoble','France'); INSERT INTO CLIENT (NOM, ADRESSE_RUE, ADRESSE_CP, ADRESSE_VILLE, PAYS) VALUES ('DUPONT', '17 rue du Sentier', '74000','Annecy','France'); INSERT INTO CLIENT (NOM, ADRESSE_RUE, ADRESSE_CP, ADRESSE_VILLE, PAYS) VALUES ('GARNIER', '147 avenue Victor Hugo', '62110','Henin Beaumont','France'); INSERT INTO CLIENT (NOM, ADRESSE_RUE, ADRESSE_CP, ADRESSE_VILLE, PAYS) VALUES ('DUPONT', '20 rue Royale', '74000','Annecy','France'); SELECT NOM FROM CLIENT WHERE ADRESSE_VILLE='Annecy'; "; // queries separated with ";" - 1 SQL query = 1 line ! function multipleSqliteQueries($db,$sql) { $array = explode("\n",$sql); for($i=0;$i < count($array)-1;$i++) { sqlite_query($db,$array[$i]); echo "Requète ".$i." (".$array[$i].") -> OK !<br>\n"; // show the result } } multipleSqliteQueries($db,$sql); // call the function TEAM17

« previous php.notes (#75260) next »