I'm a newbie and I would know which is the best way to interact with mysql db through php?what kind of available interface is better to using? mysqli o pdo?
Asked
Active
Viewed 518 times
3
-
When you ask question, So shows a _suggestion_ list. After you post it SO shows _related_ questions. Did you ever see those? – Shiplu Mokaddim Feb 10 '12 at 13:20
-
Possible duplicate of [What is difference between mysql,mysqli and pdo?](http://stackoverflow.com/questions/2190737/what-is-difference-between-mysql-mysqli-and-pdo) – justkt Nov 24 '15 at 16:44
1 Answers
5
Have a gander at What is the difference between MySQL, MySQLi and PDO?
Accepted answer copied in below, for people who don't have a mouse to click links with :)
Author: Matthew Flaschen
There are (more than) three popular ways to use MySQL from PHP.
- The mysql functions are procedural and use manual escaping.
- mysqli is a replacement for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements.
- PDO (PHP Data Objects) is a general database abstraction layer with support for MySQL among many other databases. It provides prepared statements, and significant flexibility in how data is returned.
I would recommend using PDO with prepared statements. It is a well-designed API and will let you more easily move to another database (including any that supports ODBC) if necessary.
-
Nope, I'll go Google that. I mainly just get on here and answer stuff, there's a fair bit of SO stuff I don't know. – Joe Feb 10 '12 at 00:57
-
@Joe true.. but it's fair to say that the chances of PDO being introduced in some form or another on stackoverflow is pretty high. If someone asked a simple `strtotime` question would you just assume that a basic date-formatting question had NEVER been asked before? At the same time you've never seen a question closed or flagged as a dupe before? – Mike B Feb 10 '12 at 02:51
-
I've seen closed questions, I've seen people answer with "Possible duplicate: [link]" (which is essentially what I just did), and if I take the approach of "It's probably been asked before" I may as well just go round saying "Duplicate" on the vast majority of questions. I've tried to be helpful by giving the link to the duplicate which had a good answer, and copying in the answer for lazy people. – Joe Feb 10 '12 at 03:04
-
@MikeB its my mistake. I didn't read your comment earlier. Now I understand. :) Now deleting my comments. Thanks :) – Shiplu Mokaddim Feb 11 '12 at 14:30