且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP:PDO查询不返回任何结果,但是同一查询在phpmyadmin中返回4个结果?

更新时间:2023-02-22 10:18:13

我认为您没有在单引号中包含这些参数.试试这个代码

I think you were not including the params in single quotes. Try this code

$query = "SELECT `ent`.`Entity_Id`, `ent`.`Profile_Pic_Url`, `ent`.`First_Name`, `ent`.`Last_Name`, `ent`.`Last_CheckIn_Place`, `comments`.`Content`
      FROM   `checkin_comments` AS `comments`
      JOIN   `entity` AS `ent`
      ON     `comments`.`Entity_Id` = `ent`.`Entity_Id`
      LEFT JOIN `friends` AS `f`
      ON     `ent`.`Entity_Id` = ':entityId'
      WHERE  `comments`.`Chk_Id` = ':checkInId'
      AND    `f`.`Category` != 4
      GROUP BY `comments`.`Comment_Id`
      ";

// Bind the parameters to the query
$data = Array(":checkInId" => (int)$checkInId, ":entityId" => (int)$userId);

我希望这会有所帮助.