pdo to mysqli or mysql driver

Posted on 2013-09-01
Medium Priority
Last Modified: 2013-09-01
can pdo connect to mysqli or mysql (soon to be depracated) driver
Question by:rgb192

Assisted Solution

Argenti earned 500 total points
ID: 39456687
Yes, of course. Here you have the documentation needed.

And here a sample code:

$dbh = new PDO('mysql:host='.HOST.';dbname='.DATABASE,USERNAME,PASSWORD);
$sth = $dbh->query('SELECT id,name,email FROM users');
$user = $sth->fetch(PDO::FETCH_ASSOC);

Open in new window

And here is a nice tutorial for PDO to connect to your database.
LVL 62

Accepted Solution

Julian Hansen earned 500 total points
ID: 39456688
Not really a question.

PDO is a library for connecting to MySQL
MySQLi is a library for connecting to MySQL

They are different implementations of functionality to achieve the same end.

They are not interchangeable in the sense you can use a PDO object to invoke a MySQLi method.

They all can connect to the same MySQL server database - think of it as different roads to get to the same city.
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 39456693
No, PDO requires the 'php_pdo' extension plus one of the other extensions like 'php_pdo_mysql'.  At least in the way you have to write the code, it does not appear to use the other driver directly.

LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 500 total points
ID: 39456742
This article should answer most of your questions.  MySQLi is an API for connecting to MySQL data bases.  PDO is a data-object API for connecting to many different kinds of data bases.  There is a bibliography at the end of the article if you want to learn more about these database extensions.

Please read it over and if you still are unsure about how the parts relate, please post back and I'll try to clarify.

Author Closing Comment

ID: 39457353

PDO is a library for connecting to MySQL
MySQLi is a library for connecting to MySQL

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Exchange database can often fail to mount thereby halting the work of all users connected to it. Finding out why database isn’t mounting is crucial and getting the server back online. Stellar Phoenix Mailbox Exchange Recovery is a champion product t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question