2011年3月17日星期四

Chad Lung's Blog: A quick intro to using PHP PDO with MySQL


Chad Lung has posted an introduction to PDO, PHP Data Objects, in a simple PHP script:



PHP PDO (PHP Data Objects) ship with PHP 5.1 and above and is very easy to work with. Today I'm going to show you one way of performing CRUD actions on a MySQL database using PDO. Keep in mind what I'll show you is only one way of doing things and just a fraction of what PDO can do.


He shows how to connect it to your MySQL database (via the connect string) and, based on his sample "pdo-demo.users" table, use prepared statements to insert and select data into/out of the table. There's a full code listing at the end showing a comprehensive view of each of the types - select, insert, update and delete.

没有评论:

发表评论