I made a query in the database, with query()
using mysqli and num_rows
to return the number of lines, see the code:
$consulta = $mysqli -> query("SELECT * FROM tabela WHERE Pedido = '$pedido' AND Email = '$email' ");
$linhas = $consulta->num_rows;
echo $linhas;
So I decided to use prepared statements to try, and the code got bigger, like this:
$consulta = $mysqli -> prepare("SELECT * FROM tabela WHERE Pedido = ? AND Email = ?");
$consulta -> bind_param("ss",$pedido,$email);
$consulta -> execute();
$res = $consulta->get_result(); <----------
$linhas = $res->num_rows;
See the line in the code above, help me understand what this function does?
Why when I use query, I do not need to use get_result()
?
query(
prepare () )
, suggest parameters with bind_params()
, executar()
and still get results using get_result()
?