使用 DB 或 Eloquent 出错,提示 Unsupported operand types
搜索了三天,实在没招了,只好在这里斗胆提问了。
背景:
nginx+mysql+laravel5.6
测试:
DB::select('select * from tablename'); // 没问题
DB::table('tablename')->get(); //出错
tablename::select('foo')->get(); //出错
出错提示:Unsupported operand types
出错段落:
public static function flatten($array, $depth = INF)
{
$result = [];
foreach ($array as $item) {
$item = $item instanceof Collection ? $item->all() : $item;
if (! is_array($item)) {
$result[] = $item;
} elseif ($depth === 1) {
$result = array_merge($result, array_values($item));
} else {
$result = array_merge($result, static::flatten($item, $depth - 1)); //些处为出错点
}
}
return $result;
}
这个问题非常奇怪,原生mysql查询一切正常,但无法使用DB和Eloquent功能,让人很无语啊。
希望能得到你们的帮忙,谢谢!
推荐文章: