我尝试在同一个查询中使用store_result()
和get_result()
,但它说
Call to a member function fetch_assoc() on boolean
This链接使用了它们,我想这对他有用。
这是我的代码
$stmtgetproducts = $mysqli->prepare("SELECT * FROM store_products sp
INNER JOIN store_product_categories spc ON sp.product_category=spc.id
WHERE sp.store_id = ? ORDER BY sp.product_views DESC");
$stmtgetproducts->bind_param("i",$storeid);
$stmtgetproducts->execute();
$stmtgetproducts->store_result();
$rows = $stmtgetproducts->num_rows;
$getproducts = $stmtgetproducts->get_result();
while($products = $getproducts->fetch_assoc()){
//Code to display rows.
}
答案 0 :(得分:0)
完成这个问题。
取得的方法来自Rajdeep Paul
$getproducts = $stmtgetproducts->get_result();
$rows = $getproducts->num_rows;
答案 1 :(得分:0)
不,没有办法。您只能使用其中之一。