My head has been wrapped around optimizing my queries today for my inventory server back-end. I started with the MySQL extension, because I’m using MySQL. However, I wanted to create a wrapper that would handle common code. I got so far as to load scripts from the file system, but the problem came with parameters. I found that MySQLi was good for supporting the question mark “?” tag as a parameter so long as I specified the datatypes ahead of type for proper formatting. I believe I hit the jack pot when I discovered that PDO actually supported named parameters. I’ve condensed my code down to a third of it’s original space and made things a bit more manageable. I need some sleep.
posted by Dedric Mauriac on Leonis using a blogHUD : [blogHUD permalink]

4 Responses to MySQL, MySQLi, PDO?

  1. PDO is quite fun ^_^

    It’s good for security because it can be configured to auto-escape variables.

  2. MySQLi and PDO both support escaping bound parameters. The MySQL extension has a separate call (very long) that makes for messy code: mysql_real_escape_string

    PDO by far looks the cleanest, and appears to have support for other databases besides MySQL.

  3. Key phrase was “auto-escape” 😛

  4. That was what I was after. Both auto-escaping, and named parameters. 🙂

%d bloggers like this: