2

Is it an good approach to to convert old mysql_ functions to PDO using two connections?

connection 1 - mysqli (procedural: for quick conversion of old mysql_ to mysqli_ )

connection 2 - PDO (for all new functions and gradually converting old mysql_ functions to PDO)

Or is there any better approach.

fmask
  • 481
  • 7
  • 18
  • No its not, at least for me. Why do double the work and convert first to a mid term solution? Move once to the one you like. – Hanky Panky Oct 27 '13 at 07:45
  • This is a good question and there is no reason for close nor downvote. – Your Common Sense Oct 27 '13 at 07:47
  • Thanks even if we are on a good production website. And need a quick solution, still we go for 1 connection option? – fmask Oct 27 '13 at 07:47
  • Your last question is not clear. What's up with good production website? Why "quick solution"? – Your Common Sense Oct 27 '13 at 07:50
  • Thanks for you quick response. Actually it is client requirement he want a quick conversion to PHP5.5 Dev where as code use old mysql_ functions. If we convert it to PDO it'll takes weeks but if we use mysqli_ it'll take few days. – fmask Oct 27 '13 at 07:55
  • Well, I hope you understand that there cannot be a sane answer for an insane demand. Yet I still don't understand "2 connection dilemma". Don't you have a development server where rewritten to mysqli version have to be tested? Don't you use DB abstraction library? You'd better start for using one, which is far more important than underlying driver – Your Common Sense Oct 27 '13 at 07:59
  • Thanks, eventually we convinced him to have some pertinence. lol – fmask Oct 27 '13 at 08:03

1 Answers1

1

To me, such a setup makes not too much sense.

There is no need to hurry, and use mysqli for quick conversion.

Just convert to PDO, having one single PDO connection. That's all.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • Thanks for your answer. But if client want a quick solution then what are possibilities. – fmask Oct 27 '13 at 07:49
  • Just lie to him, like it have to be for any insane demands. – Your Common Sense Oct 27 '13 at 07:51
  • 3
    A `quick` solution today will cause you a lot of headache tomorrow and that will take far more time than it would take to provide a proper solution today. – Hanky Panky Oct 27 '13 at 07:53
  • upgrading to php 5.5 is important, and perhaps even urgent... but why has migrating from mysql not been important since... well at least when the highest voted php question on s/o was originally asked in 2008? http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php/60496#60496 – Ryan Oct 27 '13 at 08:06
  • @Ryan one can make use of prepared statements even with old mysql ext all right. And there is not a single reason for "urgent" upgrade. – Your Common Sense Oct 27 '13 at 08:13
  • @YourCommonSense I am intrigued: http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php boldly and explicitly says mysql does NOT support prepared statements. Is that not correct? – Ryan Oct 27 '13 at 08:33
  • @Ryan prepared statement is just a principle, and mysqli doesn't hold copyright for its certain implementation. And of course such a principle can be implemented manually. There are other answers in the question you linked, beside dull and misleading accepted one. – Your Common Sense Oct 27 '13 at 08:49
  • Your comment is also bold, explicit, and respectable - thank you. I'd really enjoy buying you a cup of coffee one day. – Ryan Oct 27 '13 at 09:02