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) {
| if ($this->db_connect_id) {
|
Line 50 | Line 69 |
---|
/** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version
|
/** * 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 */
|
* @return string sql server version */
|
function sql_server_info($raw = false)
| function sql_server_info($raw = false, $use_cache = true)
|
{ global $cache;
|
{ global $cache;
|
if (empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)
| 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;
|
{ $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);
|
$cache->put('sqlite_version', $this->sql_server_version);
|
| }
|
}
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
| }
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
|
Line 276 | 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;
|
}
/**
| }
/**
|