Pagination
This commit is contained in:
16
lib/DBH.php
16
lib/DBH.php
@@ -12,6 +12,7 @@ class DBH
|
||||
|
||||
function log($line)
|
||||
{
|
||||
return;
|
||||
static $f = false;
|
||||
static $failed = false;
|
||||
|
||||
@@ -38,10 +39,10 @@ class DBH
|
||||
$this->db_user = $db_user;
|
||||
$this->db_host = $db_host;
|
||||
|
||||
$this->dbh = @sqlite_open($db_name, 0666, $error_msg);
|
||||
|
||||
if (!$this->dbh) {
|
||||
DBH::log("[error] connection to database failed: $error_msg");
|
||||
try {
|
||||
$this->dbh = new SQLite3($db_name, SQLITE3_OPEN_READWRITE);
|
||||
} catch (Exception $e) {
|
||||
DBH::log("[error] connection to database failed: " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,11 +51,12 @@ class DBH
|
||||
|
||||
function query($q)
|
||||
{
|
||||
$res = @sqlite_query($this->dbh, $q, SQLITE_BOTH, $error_msg);
|
||||
$res = $this->dbh->query($q);
|
||||
|
||||
if (!$res) {
|
||||
DBH::log("[error] ".$q);
|
||||
DBH::log("[error_msg] " . $error_msg . " " . @sqlite_error_string(@sqlite_last_error(($this->dbh))));
|
||||
$error_msg = $this->dbh->lastErrorMsg();
|
||||
DBH::log("[error_msg] " . $error_msg);
|
||||
$this->last_error = $error_msg;
|
||||
|
||||
$e = debug_backtrace();
|
||||
@@ -84,7 +86,7 @@ class DBH
|
||||
|
||||
function fetchRow($res)
|
||||
{
|
||||
return @sqlite_fetch_array($res, SQLITE_ASSOC);
|
||||
return $res->fetchArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
$php_str_sql_options_array = array(
|
||||
"str_sql_date_format" => "Y-m-d",
|
||||
"str_sql_datetime_format" => "Y-m-d H:i:s",
|
||||
"str_sql_quote_func" => "sqlite_escape_string");
|
||||
"str_sql_quote_func" => "SQLite3::escapeString");
|
||||
/**
|
||||
* This method validates the sql insert string must always be used in conjunction with an insert to the db
|
||||
* @return string
|
||||
@@ -13,7 +13,6 @@ $php_str_sql_options_array = array(
|
||||
function kl_str_sql()
|
||||
{
|
||||
GLOBAL $php_str_sql_options_array;
|
||||
$f = $php_str_sql_options_array['str_sql_quote_func'];
|
||||
|
||||
$narg = func_num_args();
|
||||
$args = func_get_args();
|
||||
@@ -39,7 +38,7 @@ function kl_str_sql()
|
||||
if (is_null($args[$narg])) {
|
||||
$res .= 'NULL';
|
||||
} else {
|
||||
$res .= "'".$f($args[$narg])."'";
|
||||
$res .= "'".SQLite3::escapeString($args[$narg])."'";
|
||||
}
|
||||
$narg++;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user