1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| <? class SQLite { function __construct($file) { try { $this->connection = new PDO('sqlite:'.$file); } catch(PDOException $e) { try { $this->connection = new PDO('sqlite2:'.$file); } catch(PDOException $e) { exit(false); } } } function __destruct() { $this->connection=null; } function query($sql) { return $this->connection->query($sql); } function get_record($sql) { $list = array(); foreach($this->query($sql) as $rstmp) { $list[]=$rstmp; } return $list; } function execute($sql) { return $this->query($sql)->fetch(); } function record_array($sql) { return $this->query($sql)->fetchAll(); } function record_count($sql) { return count($this->RecordArray($sql)); } function record_last_id() { return $this->connection->lastInsertId(); } } ?>
|