CodeIgniter Forums

Full Version: Can´t select data PDO with CI 2.2.1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[UPDATE]
Does not mater if it is a JOIN. I can´t get data period.

So this does not work:
$this->db->get('objects');

This will return nothing. However this will work:
$data = array(
'moName' => 'something'
);
$this->db->insert('objects', $data);

So there should not be anything about file/directory rights.
[/UPDATE]

So i had this problem (CI 2.2.0):
http://forum.codeigniter.com/thread-6130...#pid315991

I upgraded to CI 2.2.1 and now i can´t fetch JOIN data...wonderful!

Tried the generated SQL string directly in my SQLLite DB and it will fetch at least 4 posts. But when i run it using CI...nothing will get back.

I skimmed the change log and it should not behave like this:

PHP Code:
       $this->db->select("*");
 
       $this->db->from("objects");
 
       $this->db->join("objects_data""objects.moId = objects_data.modObject");
 
       $this->db->join("component_types""objects.moComponenttype = component_types.mctId");
 
       $this->db->where("objects.moType = 'page'"); 
 
       $query $this->db->get();
 
       print_r($query); 

This will generate the SQL string that will WORK when executed in the SQLLite db.:
SELECT *
FROM objects
JOIN objects_data ON objects.moId = objects_data.modObject
JOIN component_types ON objects.moComponenttype = component_types.mctId
WHERE objects.moType = 'page'
do a...
Code:
print_r($query->result());
(04-08-2015, 05:19 AM)Avenirer Wrote: [ -> ]do a...

Code:
print_r($query->result());

Yeah did that earlier. It is empty. Here is the query result (print_r($query))

CI_DB_pdo_result Object
(
[num_rows] => 0
[conn_id] => PDO Object
(
)

[result_id] => PDOStatement Object
(
[queryString] => SELECT *
FROM objects
JOIN objects_data ON objects.moId = objects_data.modObject
JOIN component_types ON objects.moComponenttype = component_types.mctId
WHERE objects.moType = 'page'
)

[result_array] => Array
(
)

[result_object] => Array
(
)

[custom_result_object] => Array
(
)

[current_row] => 0
[row_data] =>
)
This may be one stupid question... but do you have PDO installed?
(04-08-2015, 05:47 AM)Avenirer Wrote: [ -> ]This may be one stupid question... but do you have PDO installed?

Yes, or else i would get an error. I have run the exact same code in earlier (hacked) version of CI 2.0.0.

And here is an update. Can´t even run this code:

$query = $this->db->get('objects');

Nothing get´s back. I really don´t know what is wrong here.

my db config:
$active_group = 'admin';
$active_record = TRUE;

$db['admin']['hostname'] = 'sqlite:C:/work/projects/pio/res/pio_test.sqlite';
$db['admin']['username'] = '';
$db['admin']['password'] = '';
$db['admin']['database'] = '';
$db['admin']['dbdriver'] = 'pdo';
$db['admin']['dbprefix'] = '';
$db['admin']['pconnect'] = TRUE;
$db['admin']['db_debug'] = TRUE;
$db['admin']['cache_on'] = FALSE;
$db['admin']['cachedir'] = '';
$db['admin']['char_set'] = 'utf8';
$db['admin']['dbcollat'] = 'utf8_general_ci';
$db['admin']['swap_pre'] = '';
$db['admin']['autoinit'] = TRUE;
$db['admin']['stricton'] = FALSE;
(04-08-2015, 05:36 AM)Jacker Wrote: [ -> ]
(04-08-2015, 05:19 AM)Avenirer Wrote: [ -> ]do a...


Code:
print_r($query->result());

Yeah did that earlier. It is empty. Here is the query result (print_r($query))

print_r($query) is not the same as print_r($query->result()). Nothing in $query will actually be populated with information from the database until you call a method to retrieve/verify data, such as result() or num_rows().
(04-13-2015, 08:59 AM)mwhitney Wrote: [ -> ]
(04-08-2015, 05:36 AM)Jacker Wrote: [ -> ]
(04-08-2015, 05:19 AM)Avenirer Wrote: [ -> ]do a...



Code:
print_r($query->result());

Yeah did that earlier. It is empty. Here is the query result (print_r($query))

print_r($query) is not the same as print_r($query->result()). Nothing in $query will actually be populated with information from the database until you call a method to retrieve/verify data, such as result() or num_rows().

Does not mather. Active Records PDO drivers in CO 2.x is horrible broken. I have tried just about everything. The result is still the same. Even if my SQL will generate results....Acitve Records still returns nothing. I will go on without Active Records writing the PDO stuff myself.