php - How do I check for emulated prepared statements in ADOdb? -


i've been using adodb many years database abstraction , query caching layer. lately switched prepared statements, security, , became curious way (or not) implemented.

quote documentation prepare method: “returns array containing original sql statement in first array element; remaining elements of array driver dependent. if there error, or emulating prepare( ), return original $sql string.

testing statement variable with:

$stmt = $db->prepare("select * pages id = ?"); print_r($stmt); 

on connections opened ‘mysql’ or ‘mysqli’ parameter original query string returned – meaning prepared statement emulated, guess. connection opened ‘pdo_mysql’ returns (from print_r()):

array (     [0] => select * pages id = ?      [1] => pdostatement object ([querystring]=>select * pages id = ?)  )  

can take definite proof of real prepared statement? if not, know of quick , dirty way check server-side (something in query log, or maybe in mysqlproxy)? tried read library source, got lost halfway...

can take definite proof of real prepared statement

as documentations says, if try prepare statement using driver not support prepared statements, given query returned, otherwise array query first element. check if prepared statement going emulated check if $stmt array. assume wouldn't try prepare passing array, 1 should enough:

$stmt = $db->prepare("select * pages id = ?"); if(is_array($stmt)){     //prepared } else{     //emulated } 

if confused why mysqli driver returns sql despite mysqli driver supporting prepared statements, it's explained in line 662 of drivers/adodb-mysqli.inc.php:

// prepare() not supported because mysqli_stmt_execute not return recordset, // returns bound variables. 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -