Reputation: 185
I'm beginner with Joomla! and i'm trying to get informations from my database, but it doesn't work, Joomla! display a blank page, which means there is an execution error with my PHP code.
Here is the code of my request :
$query
->select($db->quoteName(array('orders.order_id', 'user.first_name', 'user.last_name')))
->from($db->quoteName('#__orders', 'orders'))
->join('LEFT', $db->quoteName('#__userinfos', 'user').' ON ('.$db->quoteName('orders.user_id').' = '.$db-quoteName('user.user_id') .')')
->where($db->quoteName('address_type').' = '.$db->quote('BT'));
I know the error comes from the join function, because when i comment it, there is no error
Here is the SQL request i want to call
SELECT orders.order_id, users.first_name, users.last_name
FROM prefix_orders orders LEFT JOIN prefix_userinfos users
ON orders.ser_id = users.user_id
WHERE address_type = 'BT'");
thanks
Upvotes: 1
Views: 114
Reputation: 16488
You have a syntax error in the last quote of the join method:
$db-quoteName('user.user_id')
instead of
$db->quoteName('user.user_id')
Illusive one, I would say.
Upvotes: 3
Reputation: 21
You need to specify where the column 'address_type' comes from (users or orders table), otherwise mysql can't find it in your query.
Upvotes: 0