From 84e5879f7e7f9aabc16e6d00095237c2efa4533f Mon Sep 17 00:00:00 2001 From: tenzap Date: Mon, 30 Dec 2024 15:43:36 +0100 Subject: [PATCH] access sqlite3 db through sqlite3 instead of PDO PDOStatement::rowCount() is source of problems (used by num_rows() in ci3) See: https://stackoverflow.com/questions/883365/row-count-with-pdo As a consequence, switch to PHP's sqlite3 driver --- application/config/database.php | 8 ++++---- application/helpers/kalkun_helper.php | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/application/config/database.php b/application/config/database.php index ea1476489..9fcb9a24b 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -142,12 +142,12 @@ ); $db['kalkun_sqlite3'] = array( - 'dsn' => 'sqlite:/path/to/kalkun.sqlite', - 'hostname' => 'localhost', + 'dsn' => '', + 'hostname' => '', 'username' => '', 'password' => '', - 'database' => '', - 'dbdriver' => 'pdo', + 'database' => '/path/to/kalkun.sqlite', + 'dbdriver' => 'sqlite3', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT !== 'production'), diff --git a/application/helpers/kalkun_helper.php b/application/helpers/kalkun_helper.php index 069ccabea..873f4a54a 100644 --- a/application/helpers/kalkun_helper.php +++ b/application/helpers/kalkun_helper.php @@ -225,7 +225,7 @@ function is_ajax() function get_database_property($driver) { // valid and supported driver - $valid_driver = array('postgre', 'mysql', 'mysqli', 'pdo'); + $valid_driver = array('postgre', 'mysql', 'mysqli', 'sqlite3'); if ( ! in_array($driver, $valid_driver)) { @@ -250,12 +250,11 @@ function get_database_property($driver) $mysqli['escape_char'] = '`'; $mysqli['driver'] = 'mysqli'; - $pdo['name'] = 'sqlite'; - $pdo['file'] = 'sqlite'; - $pdo['human'] = 'SQLite3 (Using PDO)'; - $pdo['escape_char'] = ''; - $pdo['driver'] = 'pdo_sqlite'; - + $sqlite3['name'] = 'sqlite'; + $sqlite3['file'] = 'sqlite'; + $sqlite3['human'] = 'SQLite3'; + $sqlite3['escape_char'] = ''; + $sqlite3['driver'] = 'sqlite3'; return ${$driver}; }