| | |
| | | |
| | | |
| | | /** |
| | | * Connection state checker |
| | | * |
| | | * @param boolean True if in connected state |
| | | */ |
| | | function is_connected() |
| | | { |
| | | return PEAR::isError($this->db_handle) ? false : true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Execute a SQL query |
| | | * |
| | | * @param string SQL query to execute |
| | |
| | | */ |
| | | function query() |
| | | { |
| | | if (!$this->is_connected()) |
| | | return NULL; |
| | | |
| | | $params = func_get_args(); |
| | | $query = array_shift($params); |
| | | |
| | |
| | | */ |
| | | function _fetch_row($result, $mode) |
| | | { |
| | | if ($result === FALSE || PEAR::isError($result)) |
| | | if ($result === FALSE || PEAR::isError($result) || !$this->is_connected()) |
| | | return FALSE; |
| | | |
| | | return $result->fetchRow($mode); |
| | |
| | | $data = file_get_contents($file_name); |
| | | |
| | | if (strlen($data)) |
| | | sqlite_exec($dbh->connection, $data); |
| | | if (!sqlite_exec($dbh->connection, $data, $error) || MDB2::isError($dbh)) |
| | | raise_error(array('code' => 500, 'type' => 'db', |
| | | 'line' => __LINE__, 'file' => __FILE__, 'message' => $error), TRUE, FALSE); |
| | | } |
| | | |
| | | |