tp5使用isEmpty()报错

浏览:3031 发布日期:2018/05/19 分类:求助交流
if ($result->isEmpty()) {
throw new ThemeException();
只要使用就报错


Fatal error: Call to a member function isEmpty() on a non-object in C:\wamp\www\thinkphp\application\api\controller\Theme.php on line 35
[1] ErrorException in Theme.php line 35
Call to a member function isEmpty() on a non-object
* 多个id+分隔符或者将多个id序列化成json并在query中传递
*/
public function getSimpleList($ids = '')
{
$validate = new IDCollection();
$validate->goCheck();
$ids = explode(',', $ids);
$result = ThemeModel::with('topicImg,headImg')->select($ids);
// $result = ThemeModel::getThemeList($ids);
if ($result->isEmpty()) {
throw new ThemeException();
//
// 框架会自动序列化数据为JSON,所以这里不要toJSON!
// $result = $result->hidden(['products.imgs'])
// ->toArray();
// $result = $result->hidden([
// 'products.category_id','products.stock','products.summary']);
return $result;
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>