0

I have been working on this project in php. Half of the project has been done using mysql_query and the newest modules have been made using mysqli. There a lot of modules and i don't want to change the code. Will it create problems if is like this. Or should i convert it all to mysqli. I would be grateful if somebody suggest me whats the right method?

4
  • 2
    You will have to. Cause mysql is deprecated and will be removed in one of the next versions of PHP. So your modules work then anymore either. Oct 31, 2013 at 10:41
  • It will also be a lot more difficult to maintain in the future, because you'll inevitably end up with script execution that (mis)combines both and returns no results.... witness the number of questions that crop up each day here doing exactly that
    – Mark Baker
    Oct 31, 2013 at 10:44
  • You should decide for one of them because of consistency, but i don't think there will be any problems to use both. Oct 31, 2013 at 10:45
  • There is at least 3 years to mysql is being removed from a future version of PHP (5.5 is supported 3 years after release) and it is not sure at all that mysql will be removed after 3 years. But eventually it will. Just saying ... Oct 31, 2013 at 10:48

1 Answer 1

2

IMHO, the best way to handle this properly is to create your own thin database layer and encapsulate calls to mysql_query in your own functions.

Also, another option is to switch to PDO, which is a bit nicer, as it supports named parameters and more databases. Here's a comparison between mysqli and PDO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.