我正在尝试使用 MEDOO 连接两个表,我面临的问题是我正在构建的查询没有返回任何数据(它返回 false)。我已经按照这个普通的 SQL 代码完成了查询
select posts.id, title, extract, img_principal, users.username, date, category, platform, url from posts, users where users.username in (select username from users where users.id = posts.author);
结果是这个:
$lastPost = 10;
$database = new medoo([
'database_type' => 'mysql',
'database_name' => 'notijuegosdb',
'server' => 'localhost',
'username' => 'root',
'password' => '',
'charset' => 'utf8'
]);
$database->select("posts", [
"[>]users" => ["author" => "users.id"]
], [
'posts.id',
'posts.title',
'posts.extract',
'posts.img_principal',
'users.username',
'posts.date',
'posts.category',
'posts.platform',
'posts.url'
], [
'posts.id[<]'=> $lastPost
]);
当我将 SQL 代码直接用于数据库时,它可以完美运行,因此这可能是我构建查询的方式的问题......不知道可能出了什么问题。
提前非常感谢。