php - Can MYSQLI prepare statements independently of execution? -
i running site makes heavy use of search function. exploring ways speed , smooth search.
my question is, can declare mysqli query , establish connection/prepare independently of executing query , binding results , parameters?
this way can declare query , connection once, assumably saving processing time. mess parameters , results of query independently.
the below code select x & y table. these 2 variable ones being selected, , connection same. changing element of below code parameter binded onto ?.
$query = "select x, y z x = ? "; $stmt = $conn->prepare($query);
loop through array , run query each element.
foreach($array $key) { $stmt->bind_param('s',$key); $stmt->execute(); $stmt->bind_result($x, $y); while ($stmt->fetch()) { //lalalalalal } $stmt->free_result(); }
are there inherent issues method? worth trouble way? beneficial?
thanks in advance.