I've got a query which is causing a PHP error 500 whenever I add a left join:

PHP Fatal error: Call to a member function orderBy() on a non-object

Here's the query:

$query = db_select('my_table', 'mt')
         ->extend('PagerDefault')
         ->fields('mt')
         ->fields('u', array('name')
         ->leftJoin('users', 'u', 'u.uid = mt.user_id')
         ->orderBy('mt.my_table_id', 'DESC')
         ->limit($results_per_page);

$result = $query->execute();

The query is to be used with a table + pager. If I remove the jeftJoin() and respective fields() the query works perfectly. Can anyone shed some light as to why this might be happening?

Many thanks

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top