db->fetchAll($this->select('table.metas.mid') ->join('table.relationships', 'table.relationships.mid = table.metas.mid') ->where('table.relationships.cid = ?', $this->parameter->cid) ->where('table.metas.type = ?', 'category')), 'mid'); usort($ids, function ($a, $b) { $orderA = array_search($a, $this->orders); $orderB = array_search($b, $this->orders); return $orderA <=> $orderB; }); $this->pushAll($this->getRows($ids)); } }