CodeIgniter Forums
PDO Extension - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: PDO Extension (/showthread.php?tid=11929)



PDO Extension - El Forum - 09-29-2008

[eluser]hykoh[/eluser]
Hi,

is there any PDO Database Extension for CI ? I just started to work with CI yesterday, but like to work with PDO and the "real" prepared statements for mySQL. CI has only Pseudo-prepared-statements mh ?


PDO Extension - El Forum - 09-29-2008

[eluser]xwero[/eluser]
Why don't you use PDO directly. It already is a OO database layer. Just use the model classes to group the sql statements and you could use the database.php config file if you want.


PDO Extension - El Forum - 09-29-2008

[eluser]hykoh[/eluser]
ok you're right.

but i've some modifications for my PDO ... i tried to autoload the MyPDO.php, but it doesnt work cauz my __construct function. Is it possible to create different instances ? I've a project that needs 2 databases (1 mySQL / 1 MSSQL) separatly in much files.

Can i anyhow get second parameters for DSN into the autoload ? If not, is it possible to do that within this method -> $this->load->library('MyPDO'); ?


PDO Extension - El Forum - 09-29-2008

[eluser]xwero[/eluser]
I guess you autoloaded MyPDO.php as a model, right? Well if you autoload it as a helper or a plugin the class doesn't gets instantiated and you will not have an error. In your models you can create new instances of that class.


PDO Extension - El Forum - 09-29-2008

[eluser]hykoh[/eluser]
i autoloaded it as a library .. i think a libary is that what is is ?

how can i create a new instances then at the models ? the question keeps the same Wink

$db = $this->load->helper('MyPDO'); havent any option to give parameters with it
$db = new MyPDO('xx', 'xx', 'xx', 'xx') wont work too mh ?

Thanks for ur help


PDO Extension - El Forum - 09-29-2008

[eluser]xwero[/eluser]
$db = new MyPDO(‘xx’, ‘xx’, ‘xx’, ‘xx’) will work because it's php native.

If you follow the MVC guidelines strictly it should be loaded as a model but because the loader class initializes models and libraries you have to use the load the class as a helper or plugin hack.


PDO Extension - El Forum - 09-29-2008

[eluser]Xeoncross[/eluser]
I like PDO too (since that is what most projects use) so I built an extension to PDO that offers more things. PDO provides a data-access abstraction layer - but it didn't offer "query-abstraction". My Class is kind of like the DB classes of Zend and CI in that it creates the queries while PDO creates the result objects.

http://code.google.com/p/cxpdo/

Let me know what you think Wink


PDO Extension - El Forum - 09-30-2008

[eluser]hykoh[/eluser]
Nice class xeon,

but i still missing the number one feature of PDO for me .. the prepared statements Wink


PDO Extension - El Forum - 09-30-2008

[eluser]Xeoncross[/eluser]
Consider that on the @todo list ;-)