CodeIgniter Forums

Full Version: Save JSON string (PDO) into a SQLLite DB....duplicates!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok, i tried to google this. And it took my hours to find this horrible "bug" or feature (PDO prepare?).

So i am using SQLLite as my dev db and Codeigniter 2.2.0.

The driver i am using is PDO.

When i try to save a JSON string in SQLLite that haves the word "select" in it it will save the post 2 times. So this will make dublicate inserts:
PHP Code:
$data = array(
                
'mData' => '{"select77":"korre"}',
                
'mTablet' => 12,
                
'mComponenttype' => 12,
                
'mDatahash' => '',
                
'mObject' => 11
);
$qinsert $this->db->insert('component_content'$data); 

This will not:
PHP Code:
$data = array(
                
'mData' => '{"selek77":"korre"}',
                
'mTablet' => 12,
                
'mComponenttype' => 12,
                
'mDatahash' => '',
                
'mObject' => 11
);
$qinsert $this->db->insert('component_content'$data); 

Notice i changed mData to selek77 instead of select77.

Why? Is this some "nice" PDO.prepare stuff? What can i do? It is not an option to update to CI 3 right now (for various reasons).
I tested this on fresh 2.2.1 and was unable to replicate this. So, this bug is not in framework. It's either bug of your application or sqlite library.
(04-07-2015, 03:51 PM)gadelat Wrote: [ -> ]I tested this on fresh 2.2.1 and was unable to replicate this. So, this bug is not in framework. It's either bug of your application or sqlite library.

Thank you for your answer! Yes, i do have a modified version of the PDO driver (just a few rows) in order to be able to connect to SQLLite using the PDO driver.

You have been able to connect with a SQLLite in 2.2.1 using PDO? Can i see you db config?
I already deleted that project, but I guess it was like this:
PHP Code:
$db['default']['hostname'] = 'sqlite:'.APPPATH.'config/sqlite-database.db';
$db['default']['dbdriver'] = 'pdo'
Other rows left default. Sett recursive chmod 777 on config folder.
(04-08-2015, 05:11 AM)gadelat Wrote: [ -> ]I already deleted that project, but I guess it was like this:

PHP Code:
$db['default']['hostname'] = 'sqlite:'.APPPATH.'config/sqlite-database.db';
$db['default']['dbdriver'] = 'pdo'
Other rows left default. Sett recursive chmod 777 on config folder.

Thank you for your help. I upgraded to 2.2.1 and it seems to work "out of the box"...no more duplicated posts when i use insert. However....now i canĀ“t fetch JOINed SQL statments :-(

http://forum.codeigniter.com/thread-61318.html