My SQL and php skills are very limited especially when it comes to Joomla. For at least a day now I am trying to write a query for two Joomla3 Virtuemart3 tables and get the datas but I cannot. The tables are #__virtuemart_order_userinfos and #__virtuemart_orders common fields for both are the virtuemart_order_id the fields that I need, to start with, from the two tables are:
virtuemart_order_id company last_name first_name
virtuemart_order_id order_number order_total
The rest I can add, I think....
I probably need to have a JOIN for the two tables and select the correct fields based on virtuemart_order_id
Could you write for me the code for Joomla so I can add it to a php file I have created for Invoice and Receipt?
Thank you in advance
please try the query below in joomla ..
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('a.virtuemart_order_id','a.order_total','a.order_number', 'b.company', 'b.last_name','b.first_name'))
->from($db->quoteName('#__virtuemart_orders', 'a'))
->join('Left', $db->quoteName('#__virtuemart_order_userinfos', 'b') . ' ON (' . $db->quoteName('a.virtuemart_order_id') . ' = ' . $db->quoteName('b.virtuemart_order_id') . ')');
$db->setQuery($query);
$results = $db->loadObjectList();
You can also apply conditions in where clause or can use order clause for ordering for the result. please check the link for further guidance - https://docs.joomla.org/Selecting_data_using_JDatabase
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.