Line 25 | Line 25 |
---|
*/ class dbal_sqlite extends dbal {
|
*/ class dbal_sqlite extends dbal {
|
| var $connect_error = '';
|
/** * Connect to server */
| /** * Connect to server */
|
Line 36 | Line 38 |
---|
$this->dbname = $database;
$error = '';
|
$this->dbname = $database;
$error = '';
|
$this->db_connect_id = ($this->persistency) ? @sqlite_popen($this->server, 0666, $error) : @sqlite_open($this->server, 0666, $error);
| if ($this->persistency) { if (!function_exists('sqlite_popen')) { $this->connect_error = 'sqlite_popen function does not exist, is sqlite extension installed?'; return $this->sql_error(''); } $this->db_connect_id = @sqlite_popen($this->server, 0666, $error); } else { if (!function_exists('sqlite_open')) { $this->connect_error = 'sqlite_open function does not exist, is sqlite extension installed?'; return $this->sql_error(''); } $this->db_connect_id = @sqlite_open($this->server, 0666, $error); }
|
if ($this->db_connect_id) { @sqlite_query('PRAGMA short_column_names = 1', $this->db_connect_id);
|
if ($this->db_connect_id) { @sqlite_query('PRAGMA short_column_names = 1', $this->db_connect_id);
|
| // @sqlite_query('PRAGMA encoding = "UTF-8"', $this->db_connect_id);
|
}
|
}
|
| |
return ($this->db_connect_id) ? true : array('message' => $error); }
/** * Version information about used database
|
return ($this->db_connect_id) ? true : array('message' => $error); }
/** * Version information about used database
|
| * @param bool $raw if true, only return the fetched sql_server_version * @param bool $use_cache if true, it is safe to retrieve the stored value from the cache * @return string sql server version
|
*/
|
*/
|
function sql_server_info()
| function sql_server_info($raw = false, $use_cache = true)
|
{
|
{
|
return 'SQLite ' . @sqlite_libversion();
| global $cache;
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false) { $result = @sqlite_query('SELECT sqlite_version() AS version', $this->db_connect_id); $row = @sqlite_fetch_array($result, SQLITE_ASSOC);
$this->sql_server_version = (!empty($row['version'])) ? $row['version'] : 0;
if (!empty($cache) && $use_cache) { $cache->put('sqlite_version', $this->sql_server_version); } }
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
|
}
/**
| }
/**
|
Line 135 | Line 172 |
---|
return false; }
|
return false; }
|
return ($this->query_result) ? $this->query_result : false;
| return $this->query_result;
|
}
/**
| }
/**
|
Line 263 | Line 300 |
---|
*/ function _sql_error() {
|
*/ function _sql_error() {
|
return array(
| if (function_exists('sqlite_error_string')) { $error = array(
|
'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
|
'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
|
'code' => @sqlite_last_error($this->db_connect_id)
| 'code' => @sqlite_last_error($this->db_connect_id),
|
);
|
);
|
| } else { $error = array( 'message' => $this->connect_error, 'code' => '', ); }
return $error;
|
}
/**
| }
/**
|