The difference in execution time would be hard to measure, as string interpolation and an implode
call is going to be orders of magnitude faster than the round-trip time to the database server. We’re talking nanoseconds versus milliseconds.
You’re asking the wrong question, though. It’s a really bad practice to be writing out literal SQL statements inside your application, it’s way too low-level to be sustainable within any non-trivial application.
What you should be using is something like Doctrine to manage your database contents. A framework like Yii or CakePHP also eliminates a lot of this super low-level implementation.
Remember when you’re using mysql_query
, you’re interfacing directly with the MySQL C driver. This is a terribly bad idea and is actually deprecated in PHP 5.5.0, generating warnings. You should not be using this in new applications. At the very least use PDO to provide a better wrapper around MySQL.
11
solved dynamic code style rather than hard coding [closed]