Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用medoo连接表返回false而不是数据_Php_Mysql_Sql_Medoo - Fatal编程技术网

Php 使用medoo连接表返回false而不是数据

Php 使用medoo连接表返回false而不是数据,php,mysql,sql,medoo,Php,Mysql,Sql,Medoo,我正在尝试使用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

我正在尝试使用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
    ]);
$lastPost=10;
$database=new-medoo([
'数据库类型'=>'mysql',
“数据库名称”=>“notijuegosdb”,
“服务器”=>“本地主机”,
'用户名'=>'根',
'密码'=>'',
“字符集”=>“utf8”
]);
$database->select(“posts”[
“[>]用户”=>[“作者”=>“用户.id”]
], [
“posts.id”,
"职位,职称",,
“posts.extract”,
“posts.img_负责人”,
“users.username”,
“posts.date”,
"职位类别",,
"岗位平台",,
“posts.url”
], [

'posts.id[您可以使用用于复杂查询的query-medoo方法对其进行归档:

$postsData = $database->query("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);")->fetchAll();
就像Medoo博士说的:

此函数用于用于复杂查询的特殊和自定义SQL查询。对于要插入的每个数据,请使用quote函数来防止SQL注入