Skip to content

Commit

Permalink
access sqlite3 db through sqlite3 instead of PDO
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tenzap committed Jan 3, 2025
1 parent 7060c95 commit 84e5879
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
13 changes: 6 additions & 7 deletions application/helpers/kalkun_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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};
}

Expand Down

0 comments on commit 84e5879

Please sign in to comment.