簡體   English   中英

PHP / Sqlite3:致命錯誤:調用未定義的函數sqlite_num_rows()

[英]PHP/Sqlite3: Fatal error: Call to undefined function sqlite_num_rows()

當我調用函數sqlite_num_rows時,我收到此錯誤。 它不能是依賴問題,因為其他Sqlite函數正在工作。 我可以打開連接並從DB獲取數據。

相對於php.net上的信息

“sqlite_num_rows($ result)”和“$ result-> numRows()”都沒有在SQLite3上運行! 你應該這樣使用:

<?php
 $db = new SQLite3('databasename.db'); 
 $result = $db->query("SELECT * FROM users"); 
 $rows = count ($result); 
 echo "Number of rows: $rows";

點擊我

遲了4年但我遇到了同樣的問題所以這里是我解決方案對任何有同樣問題的人

//$db is the database handle
$result = $db->query("SELECT * FROM table_name");
$rows = 0; //set row counter to 0
while($row = $result->fetchArray()) {
    $rows += 1; //+1 to the counter per row in result
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM