2 define('WARAQ_ROOT', '..');
3 require_once WARAQ_ROOT
.'/ini.php';
5 require_once "code.php";
9 var $type, $name, $host, $user, $password;
11 function __construct($dsn, $username = NULL, $password = NULL)
13 $this->user
= $username;
14 $this->password
= $password;
17 $this->type
= $dbconfig['type'];
18 $this->name
= $dbconfig['name'];
19 $this->host
= $dbconfig['host'];
20 $dsn = $this->getDsn();
22 parent
::__construct($dsn,$username, $password);
27 $dsn = $this->type
.':';
28 if ("sqlite" == $this->type
or "sqlite2" == $this->type
) {
31 $dsn .= 'host='. $this->host
;
32 $dsn .= ';dbname='. $this->name
;
37 function httpGet($localResource)
39 $queryString = "dbt=". $this->type
;
40 $queryString .= "&dbn=". $this->name
;
41 $queryString .= "&dbh=". $this->host
;
42 $queryString .= "&dbu=". $this->user
;
43 $queryString .= "&dbp=". $this->password
;
44 return file_get_contents($localResource->url
.'?'. $queryString);
49 $dbType = $this->getAttribute(PDO
::ATTR_DRIVER_NAME
);
50 if ('sqlite' == $dbType ||
'sqlite2' == $dbType) {
51 $query = "select name from sqlite_master where type='table'";
53 $query = "show tables";
55 $result = $this->query($query);
57 foreach ($result as $r) {
58 $tables []= new Table($r[0]);
70 function __construct($name, $columns = array())
73 $this->columns
= $columns;
76 function loadColumns($db)
78 $this->columns
= array();
80 $dbType = $db->getAttribute(PDO
::ATTR_DRIVER_NAME
);
81 if ('sqlite' == $dbType ||
'sqlite2' == $dbType) {
82 $query = "select sql from sqlite_master where type='table' and name='$table'";
83 $row = $db->query($query)->fetch();
84 $createQuery = new SqlCode($row['sql']);
85 $this->columns
= $createQuery->extractColumns();
87 $query = "show columns from $table";
88 $result = $db->query($query);
89 foreach ($result as $column) {
90 $this->columns
[]= new Column($column['Field'], $column['Type']);
94 return $this->columns
;
104 function __construct($name, $type = NULL)
112 function columnNames($row)
114 return array_keys($row);