Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $query = $noclegi_db->getQuery(true);
- $query
- ->select(array('sid'))
- ->from($noclegi_db->quoteName('#__sobipro_field_data'))
- ->where($noclegi_db->quoteName('baseData') . " = " . $noclegi_db->quote('Tylicz'), 'AND')
- ->where($noclegi_db->quoteName('lang') . " = " . $noclegi_db->quote('pl-PL'));
- $noclegi_db->setQuery($query);
- $obj_results = $noclegi_db->loadAssocList('sid');
- $obj_ids = implode(",", array_keys($obj_results));
- //print_r($obj_ids);
- $query = $noclegi_db->getQuery(true);
- $query
- //->select(array('sid','fid','baseData'))
- ->select([
- "MAX(CASE WHEN fid = 1 THEN baseData ELSE NULL END) AS name",
- "MAX(CASE WHEN fid = 3 THEN baseData ELSE NULL END) AS city",
- "MAX(CASE WHEN fid = 14 THEN baseData ELSE NULL END) AS street",
- "MAX(CASE WHEN fid = 8 THEN baseData ELSE NULL END) AS short_description",
- "MAX(CASE WHEN fid = 10 THEN baseData ELSE NULL END) AS image"
- ])
- ->from($noclegi_db->quoteName('#__sobipro_field_data'))
- ->where(["lang = 'pl-PL'","sid IN (". $obj_ids .")", "fid IN (1,3,14,8,10)"])
- ->group("sid")
- ->order($noclegi_db->quoteName('sid') . ' ASC');
- //echo $query->dump();
- $noclegi_db->setQuery($query);
- $final_results = $noclegi_db->loadObjectList();
- /*fid
- 1 nazwa
- 3 miejscowość
- 14 ulica
- 8 short description
- 10 obrazek*/
- //$my_array = array_combine(array_map('array_shift', $DBresults), array_map('array_pop', $DBresults));
- print_r($final_results);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement