Welcome Guest, Not a member yet? Register   Sign In
PDO driver issue - multiple insert
#1

Hello All,
Can anybody help me? I am using CI 2 with my mssql database. I have a big problem with PDO driver. I can't insert any data to database because of duplicate data in database. If I use a code INSERT into table (data1, data2, last_update) select 11,22, getdate()
after this insert I have 2 rows with the same data but insert time is a little different. If I use mssql driver everything is good.
I have to change a driver to PDO because I have to change apache and php to higher version but in these new versions mssql driver doesn't exist so I have to use PDO but pdo driver is not working fine.
What can I do with this?
I have to use apache, php + mssql database.
Can anybody help me?
Best regards,
Grzegorz
Best regards,
Grzegorz
Reply
#2

The CI 2.x branch has been 'End Of Life' since October 2015. In my opinion you should spend some time to upgrade your application to the 3.x branch before you ask for support. Seriously, it's time to move on.

Alot of bugs (and don't forget about security fixes!) have been resolved in all new versions. It could very well be that after you upgrade your application your database issue is already resolved.
Reply
#3

(12-19-2016, 07:16 AM)Diederik Wrote: The CI 2.x branch has been 'End Of Life' since October 2015. In my opinion you should spend some time to upgrade your application to the 3.x branch before you ask for support. Seriously, it's time to move on.

Alot of bugs (and don't forget about security fixes!) have been resolved in all new versions. It could very well be that after you upgrade your application your database issue is already resolved.

Hello Diederik,
Thank you for your quick reply. Unfortunatelly I already tested CI3 with PDO driver and have another issue.
I can not use correct database. My settings in database.php are:
$db['mssql']['hostname'] = 'sqlsrvConfusederver=192.168.1.1';
$db['mssql']['username'] = 'sa';
$db['mssql']['password'] = '*******';
$db['mssql']['database'] = 'test';
$db['mssql']['dbdriver'] = 'pdo';
$db['mssql']['dbprefix'] = '';
$db['mssql']['pconnect'] = FALSE;
$db['mssql']['db_debug'] = TRUE;
$db['mssql']['cache_on'] = FALSE;
$db['mssql']['cachedir'] = '';
$db['mssql']['char_set'] = 'utf8';
$db['mssql']['dbcollat'] = 'utf8_general_ci';
$db['mssql']['swap_pre'] = '';
$db['mssql']['autoinit'] = TRUE;
$db['mssql']['stricton'] = FALSE;
$db['mssql']['failover'] = array();

and when I call any query I am still using master database not a database what I set in my settings. I have no idea what should I change to use correct database.
I can not use a full path to a database/table in my query because I use two databases. I have to have possibility to choice correct database to get some data. In old CI I used like this:

Sample configuration in database.php
one database was settings:
$db['mssql']['database'] = 'test';
....
....
....

second one:
$db['mssql_test']['database'] = 'test2';

....
....
....

in my mssql model I had in __construct
$this->test    = $this->load->database('test', TRUE); // Load the db, and assign to the member var.
$this->test2  = $this->load->database('test2', TRUE); // Load the db, and assign to the member var.

when I tried to get data from first database I used:
$query = $this->test->query('select * from table');
from second
$query = $this->test2->query('select * from table');

If I use a single database I could use a query like this:
select * from [test].[dbo].[my_table]
but if I use more databases I can't.
Maybe somebody has any idea how to fix it?
Best regards,
Grzegorz
Best regards,
Grzegorz
Reply




Theme © iAndrew 2016 - Forum software by © MyBB