简体   繁体   中英

how to get the result of a mysql prepared query

I am using the php prepared statement to query a table to see if the given value is in a column. However i cannot seem to get a result out of the prepared query. I can get whether or not the query happened successfully but not the results from that query.

$write = $DB_Connection->prepare("SELECT * from Table where Column = ?");

$result = $write->bind_param('s', $Value);

I have tried

$write->fetch();
mysqli_stmt_fetch($write);

but these do not give me useful results. I cannot use get->results as its not mysqlnd

Any help would be appreciated.

You still have to execute the query after preparing and binding:

// execute statement
$resultset = $write->execute();

// grab data, eg., like this
$result = $resultset->fetch_all();

Besides you should check for errors somewhere as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM