php - In PDO is there a difference in performance if a int is quoted as a string? -


is there difference in performance if integer bound string in prepared pdo query? in mysql queries work either if value bound int or string, there difference in performance, or pitfalls when doing that?

$pdo = new pdo(     "mysql:host={$host};port={$port};dbname={$dbname};charset=utf8",      $username,      $password ); $statement = $pdo->prepare("select * `table` `id` = :param");  // there performance difference between 2 rows below $statement->bindvalue(":param", 5); $statement->bindvalue(":param", 5, pdo::param_int);  $statement->execute(); 

is there difference between binding parameter , specifying type, or quoting string?

if want take method specify type faster not specify type , default type pdo::param_str.

if run 1 million time avarage followed:

  • int type specified: 0.53 seconds ($stmt->bindvalue(":param", 5, pdo::param_int);)
  • no type specified: 0.66 seconds ($stmt->bindvalue(":param", 5);)
  • str type sepcified: 0.70 seconds ($stmt->bindvalue(":param", 5, pdo::param_str);)

tested php version 5.6.3; 32bit windows;


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -