/** * Find an object in the DB given the passed conditions * TODO: really inefficient at the moment */ public static function select($cond) { $db = JFactory::getDbo(); $table = LigminchaGlobalDistributed::sqlTable(); $all = LigminchaGlobalDistributed::sqlFields(); $sqlcond = LigminchaGlobalDistributed::sqlCond($cond); if (empty($sqlcond)) { return array(); } $db->setQuery("SELECT {$all} FROM {$table} WHERE {$sqlcond}"); $db->query(); if (!($result = $db->loadAssocList())) { return array(); } foreach ($result as $i => $assoc) { $result[$i] = self::newFromFields($assoc); $result[$i]->exists = true; } return $result; }