Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Why no PDO?

January 30, 2011 5:15am

Subscribe [11]
  • #1 / Jan 30, 2011 5:15am

    ipsod

    36 posts

    I’m not an expert, so that’s why I’m asking.

    Why don’t CI’s database functions use PDO?  I did some research on database security, and over and over read that the best way to fortify the database is to use parameterization.

  • #2 / Jan 30, 2011 1:03pm

    ipsod

    36 posts

    Ok, besides the theoretical why, should I implement PDO in my site, or can I trust CI’s security?

  • #3 / Jan 30, 2011 2:41pm

    Rick Jolly's avatar

    Rick Jolly

    729 posts

    If you use active record or query binding you are safe since CI uses mysql_real_escape_string() to guard against sql injection. Parameterized queries are similar to CI’s query bindings. The advantage to parameterized queries on databases that support them is speed when executing the same query but with different data multiple times. Think multiple inserts. PDO supports parameterized queries on databases that support them, but PDO can also emulate parameterized queries which is the same thing as CI’s query binding.

  • #4 / Feb 05, 2011 12:01pm

    JonoB

    133 posts

  • #5 / Feb 05, 2011 5:28pm

    ipsod

    36 posts

    Thanks JonoB, PHP Active Record looks awesome.

    Rick Jolly, I understand that it does, but this site and others like it are what led me to think that that wasn’t good enough.

    http://bobby-tables.com/

    There is only one way to avoid [injection] attacks

      * Do not create SQL statements that include outside data.
      * Use parameterized SQL calls.

    That’s it. Don’t try to escape invalid characters. Don’t try to do it yourself. Learn how to use parameterized statements. Always, every single time.

    The strip gets one thing crucially wrong. The answer is not to “sanitize your database inputs” yourself. It is prone to error.

  • #6 / Feb 05, 2011 8:43pm

    Rick Jolly's avatar

    Rick Jolly

    729 posts

    ispod, rest assured that mysql_real_escape_string() is completely safe. If it wasn’t, most php applications would be vulnerable to sql injection attack.

    Of course, we developers can screw anything up when we don’t know what we are doing.

  • #7 / Feb 05, 2011 10:38pm

    ipsod

    36 posts

    Ok, thank you, that’s great to know!  I’m satisfied with DMZ and glad to not have to change ORM’s for security reasons.

  • #8 / Feb 08, 2011 6:42am

    eBuildy

    3 posts

    Its a good question ! Why there are plenty of files for the DB instead of use the fast and very very simple to use ....

    All the time I do a new CI projet, I remove all the DB files and add my small PDO wrapper ...

  • #9 / Apr 21, 2011 6:09pm

    EugeneS

    72 posts

    Its a good question ! Why there are plenty of files for the DB instead of use the fast and very very simple to use ....

    All the time I do a new CI projet, I remove all the DB files and add my small PDO wrapper ...

    could you share your PDO wrapper ?

    thinking about using Pdo in new project so would like to know if exists any PDO library/driver for CI 2.x or have to create my own from the scratch ?

    was trying to find but i cant :\

  • #10 / Apr 23, 2011 3:31am

    Crag's avatar

    Crag

    7 posts

    I don’t understand why’d you use the PDO. CI protects you. But you know, there is a filter system in CI too. And you can always use PHP’s Sanitize Filters as well.

  • #11 / Apr 23, 2011 3:39am

    Crag's avatar

    Crag

    7 posts

    Thanks JonoB, PHP Active Record looks awesome.

    Rick Jolly, I understand that it does, but this site and others like it are what led me to think that that wasn’t good enough.

    http://bobby-tables.com/

    There is only one way to avoid [injection] attacks

      * Do not create SQL statements that include outside data.
      * Use parameterized SQL calls.

    That’s it. Don’t try to escape invalid characters. Don’t try to do it yourself. Learn how to use parameterized statements. Always, every single time.

    The strip gets one thing crucially wrong. The answer is not to “sanitize your database inputs” yourself. It is prone to error.

    With the PDO you can bind your vars/fields. But you dont have to. It’s extra work especially with big forms. But it is worth the time. But you still should sanitize your data. PHP provides some nice tools for that (there’s a link in my post above).

    It is not hard to protect your site from a SQL Injection attack. You just can’t be lazy. Every form, every page a user can type data must be sanitized.

    And CI does it all for you, if you want. Easy peasy.

  • #12 / Apr 23, 2011 4:39am

    EugeneS

    72 posts

    I don’t understand why’d you use the PDO. CI protects you. But you know, there is a filter system in CI too. And you can always use PHP’s Sanitize Filters as well.

    exists small thing - customer wants PDO to be used - this should be the answer to the WHY 😊

  • #13 / Apr 23, 2011 5:21am

    Crag's avatar

    Crag

    7 posts

    I don’t understand why’d you use the PDO. CI protects you. But you know, there is a filter system in CI too. And you can always use PHP’s Sanitize Filters as well.

    exists small thing - customer wants PDO to be used - this should be the answer to the WHY 😊

    Ok. Good enough for me. 😉

  • #14 / Apr 23, 2011 6:55pm

    Twisted1919

    500 posts

    exists small thing - customer wants PDO to be used - this should be the answer to the WHY 😊

    Customer has no clue what PDO is.

  • #15 / Apr 24, 2011 12:06am

    InsiteFX's avatar

    InsiteFX

    6819 posts

    Besides if you want PDO then write a driver for it and the database stuff!

    InsiteFX

ExpressionEngine News

#eecms, #events, #releases