【发布时间】:2014-03-05 12:35:56
【问题描述】:
我正在尝试使用 Eloquent 在 Laravel 中编写一个查询,但只需要其中的最后 5 个正在进行的字段。这是查询:
public static function past_profile_fan_likes($id) {
$latest_profile_fan_likes = DB::table('fanartists')
->join('artists', 'fanartists.artist_id', '=', 'artists.id')
->orderBy('fanartists.created_at', 'DESC')
->skip(4)
->where('fanartists.fan_id', '=', $id)
->select('artists.id', 'artists.fbid', 'artists.stage_name', 'artists.city', 'artists.state', 'artists.image_path', 'artists.description')
->get();
return $latest_profile_fan_likes;
}
当我调用这个时,我收到了这个错误:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'offset 4' at line 1 (SQL: select `artists`.`id`, `artists`.`fbid`, `artists`.`stage_name`, `artists`.`city`, `artists`.`state`, `artists`.`image_path`, `artists`.`description` from `fanartists` inner join `artists` on `fanartists`.`artist_id` = `artists`.`id` where `fanartists`.`fan_id` = ? order by `fanartists`.`created_at` desc offset 4) (Bindings: array ( 0 => '1', ))
我在这里做错了吗?跳过使用可能有问题?谢谢你的帮助。
【问题讨论】:
标签: mysql laravel laravel-4 eloquent