68

Maybe someone did a tutorial that shows the important thing: Setting everything up and using it with MySQL?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
openfrog
  • 40,201
  • 65
  • 225
  • 373
  • 2
    I found this one : [PDO_Tutorial_for_MySQL_Developers](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers). – Eric Lavoie Jun 10 '13 at 15:50
  • 3
    [(The only proper) PDO tutorial](https://phpdelusions.net/pdo) which I wrote based on the thousands questions I answered here on Stack Overflow. – Your Common Sense Feb 09 '16 at 14:06

4 Answers4

25

I think the article Why you Should be using PHP's PDO for Database Access is great. It is simple, clear, and organized.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
zx1986
  • 880
  • 2
  • 12
  • 18
  • 1
    +1 I agree - BUT, look at the comments, most of the code is syntatially inorrect, as he ommits the `prepare`. Once you get past that, it is a great guide. In fact, it is how I learned. – Mawg says reinstate Monica Jun 02 '14 at 08:43
  • They tell you to run an extra query(!) only to count the rows already returned by a query, which is a nonsense. They also tell you to "always wrap your PDO operations in a try/catch" which is a nonsense again. And they fail to explain the real PDO benefits. In essence, PDO learned from tutsplus is toilsome and error prone. – Your Common Sense Feb 09 '16 at 14:41
20

MySQL.com: Using MySQL with PDO
PHP.net: PHP Data Objects (PDO)

Deniss Kozlovs
  • 4,761
  • 2
  • 28
  • 35
Sampson
  • 265,109
  • 74
  • 539
  • 565
6

PHP.net has the best stuff. I would check out here for an example.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kitson
  • 1,650
  • 1
  • 18
  • 36
5

Something I came across with PDO and BLOBs is that you can use that for encrypted data in MySQL. A good example of using BLOBs with encryption (so information in the database itself is encrypted) can be seen in:

Project mySQL PDO: Step by step guide to working with a mySQL database with the PDO to help eliminate SQL injection along with using encryption.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
FellowCoder
  • 51
  • 1
  • 1