Introduction to PHP Data Object PDO in PHP
There are three main API options when considering connecting to a MySQL database server. PHP’s MySQL Extension. PHP’s mysqli Extension. PHP Data Object (PDO). PHP Data Object…
Complete reference guide of PHP Databases!
PHP MySQL Introduction MySQL is one of the most popular relational database system being used on the Web today. It is freely available and easy to install, however if…
How to delete records?
1) Write the delete statement: [code language=”php”] $sql = "DELETE FROM `users` WHERE `id`=:id"; [/code] 2) Prepare the query: [code language=”php”] $query = $dbh -> prepare($sql); [/code]…
How to use PDO to update the database?
1) Write the regular update statement and again, instead of values, assign the named placeholders. For example: [code language=”php”] $sql = "UPDATE `users` SET `city`= :city, `phone`…
How to use PDO to read data from the database?
1) Write the regular select statement and again, instead of values, put named placeholders. For example: [code language=”php”] $sql = "SELECT * FROM users"; [/code] 2) Prepare…
How to use PDO to insert data into the database?
The SQL code for the users table: [code language=”sql”] CREATE TABLE IF NOT EXISTS users (id int(11) NOT NULL AUTO_INCREMENT, name varchar(60) DEFAULT NULL, phone varchar(12) DEFAULT…
PDO – PHP database extension
PDO – PHP database extension PDO (PHP Data Objects) is a PHP extension through which we can access and work with databases. Though PDO is similar in…
