-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsqlite.php
50 lines (33 loc) · 1.07 KB
/
sqlite.php
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
48
49
50
<?php
class SQLite extends DataBase {
function __construct($path) {
parent::__construct("sqlite:$path");
$this->path = $path;
// print "In SubClass constructor\n";
}
function status(){
return array('path'=>$this->path, 'size'=>filesize($this->path));
}
function listTables(){
$ret = $this->column("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name",'name');
return $ret;
}
function dropTable($name){
return $this->exec("DROP TABLE $name");
}
function renameTable($oldName, $newName){
return $this->exec("ALTER TABLE $oldName RENAME TO $newName");
}
function listColumns($table){
if(!$table){return 0;}
$cols = $this->query("pragma table_info($table)")->fetchAll(PDO::FETCH_ASSOC);
foreach($cols as $col){
$rcol[$col['name']] = $col['type'];
}
return $rcol;
}
function addColumn($table, $column, $type){
return $this->exec("ALTER TABLE $table ADD COLUMN $column $type");
}
}
?>