Mazzy
Mazzy

Reputation: 14209

what type of interface use to connect to mysql through php

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?

Upvotes: 3

Views: 546

Answers (1)

Joe
Joe

Reputation: 15802

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.

  1. The mysql functions are procedural and use manual escaping.
  2. mysqli is a replacement for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements.
  3. 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.

Upvotes: 5

Related Questions