Call to a member function rowCount() on a non-object

后端 未结 3 1217
一生所求
一生所求 2021-01-27 05:07

Im having a problem with my query. I recently switched to PDO, which is kind of new to me. Now i need to use JOIN in my query to get data from another table without making two e

相关标签:
3条回答
  • 2021-01-27 05:29

    Change your query with this one:

    $query = "SELECT * FROM `friends` as F INNER JOIN `users` as U ON `F.friendID` = `U.id` WHERE `F.userID` = '{$sess_user}' AND `F.request` = '0'";
    

    And add this to your connection, it will show you the errors:

     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Set Errorhandling to Exception
    
    0 讨论(0)
  • 2021-01-27 05:32

    Don't put back ticks around the `table.field` ... You have to put them around `table`.`field`

    0 讨论(0)
  • 2021-01-27 05:41

    IMHO! I saw problems like that with PDO... and... i think it's more likely to do all with pure SQL but good then duck your head with PDO.

    0 讨论(0)
提交回复
热议问题