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.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -