-5

We are planning to upgrade our code base from PHP5 to PHP 7.

I understand that mysql_* functions are deprecated in php 7. So do we have to rewrite all our code in mysqli_* or pdo? Is there any alternative for this?

If not, which one would you suggest between mysqli_* and pdo?

We have a huge code base, so changing all the code will be a colossal task, so we're looking for an alternative.

Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
  • If you are going for **PHP7** then you have to change those codes. – Sougata Bose Dec 21 '16 at 05:13
  • 1
    Possible duplicate of [Why shouldn't I use mysql\_\* functions in PHP?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – John V. Dec 21 '16 at 05:35
  • 2
    It's completely your choice but preferably you should choose `pdo` as it is completely object oriented.But you are using `mysql_*` in your existing so `mysqli_*` is easy option to migrate – Abhishek Dec 21 '16 at 05:38

1 Answers1

1

Well, you better clear that mess up first

We are planning to upgrade our code base from PHP5 to PHP 7.

Are you talking of the "codebase"? What so you mean? May be you want to change the version of PHP you are running on your servers?

I understand that mysql_* functions are deprecated in php 7.

You understand it wrong. It was deprecated somewhere in 5.5 and removed in 7.

So do we have to rewrite all our code in mysqli_* or pdo?

Didn't you say that you wanted to change the codebase? If so, what's the problem with rewriting the codebase in order to change it?

Is there any alternative for this?

Well yes, there are. But there is little point in all of them.

If not, which one would you suggest between mysqli_* and pdo?

We would recommend PDO, if you still going to use API functions right in the code without any intermediate wrapper.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345