0

I'm a beginner in PHP, SQL, databases, etc and I'd like to hear people's opinions on whether to use PDO or MySQLi when working with databases, so far I've seen very mixed opinions.

Would you consider somebody who uses MySQLi a professional web developer? Is MySQLi up to industry standards, or is it often disregarded by employers and clients?

I'm sure this question has been asked many times before, but I'd appreciate it if you didn't mark this question as a duplicate, for the reason that I'm looking to get fresh opinions and as many as I possibly can.

Thanks in advance :]

Leon Burman
  • 391
  • 2
  • 15
  • 1
    Use `PDO`. It's simpler, object oriented and newer. If nothing, the benefit is that it's the same interface for different DB vendors (of course, the actual query language differs, but PHP around it is the same). – Mjh Jun 08 '16 at 15:08
  • @Orions Like I said, I'm looking to get fresh opinions on the matter. I've read many articles and posts on forums, however I'd like to get more answers / opinions from people involved in web development. – Leon Burman Jun 08 '16 at 15:09
  • Opinion based questions are also off topic here. But, in my opinion `PDO` is better as if in future your migrate your database from one type to other, you won't have to rewrite every query. – Ajeet Shah Jun 08 '16 at 15:16
  • `Not all questions work well in our format. Avoid questions that are primarily opinion-based, or that are likely to generate discussion rather than answers.` -http://stackoverflow.com/tour – chris85 Jun 08 '16 at 15:16
  • I dont believe it is a choice. Pdo has everything that mysqli has and more. Above all, security and mysqli will probably get deprecated in favor of pdo. – Nitin Jun 08 '16 at 15:26
  • 1
    Personally, I started off with MySQLi before learning PDO. And *personally* I find PDO simpler and easier to use, but there's nothing wrong with using MySQLi if your database supports it, which it very like does support. The important thing to remember is that you use prepared statements with placeholders, regardless of API. Security wise, MySQLi is just as good as PDO. You can also have a read at http://php.net/manual/en/mysqlinfo.api.choosing.php -- I recommend you try **both** and see which one you are most comfortable with. A lot of peoplre recommend PDO, but try both! – Qirel Jun 08 '16 at 15:33
  • 1
    @Leon here is the fresh and detailed explanation you are looking for: https://phpdelusions.net/pdo/mysqli_comparison – Your Common Sense Jun 09 '16 at 07:04

1 Answers1

0

PDO in my opinion is much better, Its supports many more databases than mysqli.
But you are probably not going to use a different one. So in your position this is not A pro.
When doing PDO prepared statements you can use named labels As so:

$stmt = $pdo->prepare("SELECT * FROM users WHERE user_name = :name");
$stmt->execute(array(':name' => $name))

In mysqli you don't have labels as (:name) you have (?) and you will have to bind parameters by order instead of labels name which in my opinion sucks.

Dea
  • 35
  • 7