Preprocessing technology for MYSQL operations in php (2) database dql query statements. Preprocessing technology for MYSQL operations in php (2) database dql query statement connect_error) {die ($ mysqli-connect_error);} create pre-compiled object $ sqlselectid, name, age, QQ from table name w php pre-processing technology for MYSQL operations (2) database dql query statements
Connect_error) {die ($ mysqli-> connect_error);} // create a pre-compiled object $ SQL = "select id, name, age, qq from table name where id
Prepare ($ SQL); // bind the parameter $ id = 10; //? Value assignment. "ssi" refers to string, string, int. The data type and sequence are one-to-one correspondence. // bind_param () the number of parameters here is variable. $ Mysqli_compile-> bind_param ("I", $ id); // bind the result set. here we use the reference parameter passing method $ mysqli_compile-> bind_result ($ name, $ age, $ qq); // execute the statement $ res = $ mysqli_compile-> execute (); // Print the cause of failure if (! $ Res) {die ("cause of failure = ". $ mysqli_compile-error);} // retrieves the binding result value while ($ mysqli_compile-> fetch () {echo "-- $ id -- $ name -- $ age -- $ qq ";} // If you want to obtain other results, you can bind the parameter again to obtain the result, but you do not need to bind the result set // release the result set $ mysqli_compile-> free_result (); // Close the resource, remove the database pre-compiled command $ mysqli_compile-> close (); // close the linked resource $ mysqli-> close ();?>
Explain (2) database dql query statement connect_error) {die ($ mysqli-> connect_error);} // create a pre-compiled object $ SQL = "select id, name, age, qq from table name w...