[英]FuelPHP database query error: Cannot access protected property
I'm a FuelPHP newbie and I have a query problem. 我是FuelPHP新手,并且有查询问题。 So, this is my code:
所以,这是我的代码:
$query = DB::query('SELECT * FROM `table`');
$result = $query->execute();
$totals = $result->_total_rows;
print_r($totals);
And i keep getting following error: Fatal error: Cannot access protected property Fuel\\Core\\Database_MySQL_Result::$_total_rows 而且我一直收到以下错误:致命错误:无法访问受保护的属性Fuel \\ Core \\ Database_MySQL_Result :: $$ total_rows
If you want the number of rows returned by a query simply 如果您只想查询返回的行数
$query = DB::query('SELECT * FROM `table`');
$result = $query->execute();
// Just count the results, it returns an int.
$totals= count($result);
Referenced here in the manual 参考此手册中
Or in your case, as you're selecting all from a table and counting it, you could use the following instead 或者在您的情况下,当您从表格中选择所有内容并对其进行计数时,可以使用以下内容代替
DB::count_records('table');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.