I'm having some trouble finding example of using JOINs with PDO in the manual and google.
Here's my code:
$query = "SELECT id, url, thirdparty, lc.category FROM links ";
$query .= "LEFT JOIN link_categories as lc ON lc.id = links.category_fk ";
$query .= "ORDER BY thirdparty ASC ";
$sql = $dbh->prepare($query);
$numResults = $sql->rowCount();
$max = 'LIMIT ' .$totaloffset.',' .PERPAGE;
$query .= $max;
$stmt = $dbh->query($query);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);//This line throws the error
I get this:
Fatal error: Call to a member function fetchAll() on a non-object in Filename on line 38
If I take out the JOIN, it works fine. Could I get some help please?
Thanks in advance!