getDatabase(); $query = $db->getQuery(true) ->select('v.*, cd.name AS tech_name') ->from($db->quoteName('#__mokosuitefield_vehicles', 'v')) ->join('LEFT', $db->quoteName('#__mokosuitefield_technicians', 't') . ' ON t.id = v.technician_id') ->join('LEFT', $db->quoteName('#__contact_details', 'cd') . ' ON cd.id = t.contact_id') ->order('v.vehicle_name ASC'); if ($status) $query->where($db->quoteName('v.status') . ' = ' . $db->quote($status)); if ($techId) $query->where('v.technician_id = ' . $techId); $db->setQuery($query, 0, $limit); return $db->loadObjectList() ?: []; } }