So I have a query in the getlistquery method of my model, except that it relies on data in another table, that sometimes is not filled. This gives me an error when that other data is not available.
But it seems that the getlistquery must return a query, I tried to use the return false but that does not work. Do I need to move that code to another method? Like getItems?
protected function getListQuery()
{
$user = Factory::getUser();
$db = $this->getDbo();
$query = $db
->getQuery(true)
->select('*')
->from($db->quoteName('#__table_profile'))
->where($db->quoteName('user_id') . " = " . $db->quote($user->id));
$db->setQuery($query);
$result = $db->loadAssoc();
//no user profile available, return false
if(!$result) return false;
}
But now I get the following error: u have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 20' at line 1
Probably because I don't return a query and now it is not complete.
getListQuery()
returns a set of rows (array or false).