0

I need to retrieve the banners_clients data only when exists banners for this client id:

Example:

banner one - client id 1

banner two - client id 1

banner three - client id 4

client id 1 - name John

client id 2 - name Lucy

client id 3 - name Holga

client id 4 - name Jorge

---- after fetch data ---

client id 1 - name John

client id 4 - name Jorge

https://pastebin.com/UCMrRT72

1

Join the banners table.

$query->select($db->quoteName(array('a.id','a.name','contact','email','extrainfo','state','checked_out','checked_out_time','metakey','own_prefix','metakey_prefix','purchase_type','track_clicks','track_impressions')));
$query->from('#__banner_clients a')
  ->join('inner', '#__banners b ON b.client_id = a.id');
  • Table 'carrosde_newclass.#__banner_clients a' doesn't exist – Uziel Almeida Oliveira Dec 19 '17 at 17:05
  • Please see my edited code – Nagarjun Dec 21 '17 at 15:27
0

Solved:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.*');
$query->from($db->quoteName('#__banner_clients', 'a'))
->join('INNER', $db->quoteName('#__banners', 'b') . ' ON (' . $db->quoteName('b.cid') . ' = ' . $db->quoteName('a.id') . ')')
->order($db->quoteName('a.name') . 'ASC');
$db->setQuery($query);
$results = $db->loadObjectList();
  • If this is the solution that you implemented, please mark your answer with the green tick. This will prevent the system from bumping this page to the top of the questions list for new volunteer attention. – mickmackusa Mar 12 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.