我想从相关表格users
中的viewed
列订购的表profiles
中获取记录。关键是我想以模型方式做到这一点。
我只想写下面的查询并获得模型。 查询:
SELECT * FROM users JOIN profiles ON users.id = profiles.user_id ORDER BY profiles.viewed DESC
答案 0 :(得分:0)
看我的例子
$Users = \User::query()
->leftJoin('UserDependence')
->where(implode(" AND ", $conditions))
->bind($parameters)
->orderBy("User.id DESC")
->bindTypes([
"email" => Column::BIND_PARAM_STR,
"active" => Column::BIND_PARAM_BOOL,
"tags" => Column::BIND_PARAM_STR
])
->execute();
$paginator = new PaginatorModel(
array(
"data" => $Users,
"limit" => 10,
"page" => (int) $this->request->get("page")
)
);