0

I'm using codeigniter 3rc2 and Sqlite3 on an embedded device running ubuntu. Server and php are configured correctly. When I try to retrieve data from the database It returns an empty query object.

Things I tried and excluded as a problem :

  • access and reading from the database works when using Python (there is data in the database)
  • no errors in codeigniter logs
  • when changing the /config/database.php to an non existing file, codeigniter throws an error as expected
  • when using querybuilder or direct sql, same result, no data
  • when changing the SQL syntax to an non existing table, codeiginiter throws an error as expected.

So what am I doing wrong here?

some codeigniter code

$q_user = $this->db->query('select * from users');
var_dump($q_user);

result in browser window

object(CI_DB_sqlite3_result)#25 (8) { ["conn_id"]=> object(SQLite3)#22 (0) { } ["result_id"]=> object(SQLite3Result)#24 (0) { } ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> NULL ["row_data"]=> NULL }

config/database.php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
'hostname' => '',
'username' => '',
'password' => '',
'database' => '/var/qcd/qcd.db',
'dbdriver' => 'sqlite3',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE,
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

1 Answers1

0

Seems like I was readin the wrong object. printing the $q_user object only shows the objects in it, not the data arrays. When I use this code, it shows the retrieved data

$query = $this->db->query('select * from users');
print_r($query);
foreach ($query->result_array() as $row)
{
    echo "<div>".print_r($row)."</div>";
}