Using the sqlite_query() Function : sqlite_query « MySQL Database « PHP






Using the sqlite_query() Function

 
<?php
     $db = sqlite_open(":memory:");
     if(!$db) die("Could not create the temporary database");

     $query = "CREATE TABLE cities(name VARCHAR(255), state VARCHAR(2))";
     sqlite_query($db, $query);
     $cities[] = array('name' => 'Chicago','state'=> 'IL');
     foreach($cities as $city) {
         $query = "INSERT INTO cities VALUES(" ."'{$city['name']}', '{$city['state']}')";
         if(!sqlite_query($db, $query)) {
          trigger_error("Could not insert city " . "'{$city['name']}, {$city['state']}");
         }
     }
     sqlite_close($db);
?>
  
  








Related examples in the same category

1.Advanced Functions
2.sqlite_query.php