第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么mysqli num_rows總是返回0?

為什么mysqli num_rows總是返回0?

絕地?zé)o雙 2019-11-04 09:32:26
我一直在獲取要使用mysqli返回的行數(shù)方面遇到麻煩。即使確實(shí)有一些結(jié)果,我每次都會(huì)得到0。if($stmt = $mysqli->prepare("SELECT id, title, visible, parent_id FROM content WHERE parent_id = ? ORDER BY page_order ASC;")){      $stmt->bind_param('s', $data->id);      $stmt->execute();    $num_of_rows = $stmt->num_rows;      $stmt->bind_result($child_id, $child_title, $child_visible, $child_parent);      while($stmt->fetch()){        //code    }    echo($num_of_rows);    $stmt->close();}為什么沒(méi)有顯示正確的數(shù)字?
查看完整描述

3 回答

?
慕斯709654

TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個(gè)贊

您需要先調(diào)用MySqli_Stmt::store_result()num_rows查找:


if($stmt = $mysqli->prepare("SELECT id, title, visible, parent_id FROM content WHERE parent_id = ? ORDER BY page_order ASC;")){  

    $stmt->bind_param('s', $data->id);  

    $stmt->execute();

    $stmt->store_result(); <-- This needs to be called here!

    $num_of_rows = $stmt->num_rows;  

    $stmt->bind_result($child_id, $child_title, $child_visible, $child_parent);  


    while($stmt->fetch()){

        //code

    }


    echo($num_of_rows);


    $stmt->close();

}

請(qǐng)參閱上的文檔MySQLi_Stmt->num_rows,該文檔顯示在頁(yè)面頂部附近(在主要說(shuō)明區(qū)域中)...


查看完整回答
反對(duì) 回復(fù) 2019-11-04
?
萬(wàn)千封印

TA貢獻(xiàn)1891條經(jīng)驗(yàn) 獲得超3個(gè)贊

嘗試$num_of_rows在if(statement)之后-在bind_param之前設(shè)置您的權(quán)限...除非那會(huì)改變您的結(jié)果。沒(méi)有更多信息很難說(shuō)。


查看完整回答
反對(duì) 回復(fù) 2019-11-04
?
素胚勾勒不出你

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊

您的查詢似乎出了點(diǎn)問(wèn)題。嘗試進(jìn)行直接查詢,例如if($stmt = $mysqli->query("SELECT id, title, visible, parent_id FROM content WHERE parent_id = YOURIDHERE ORDER BY page_order ASC;")){,看看是否仍然可以解決0個(gè)結(jié)果

查看完整回答
反對(duì) 回復(fù) 2019-11-04
  • 3 回答
  • 0 關(guān)注
  • 992 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)