public static function getIterByEnumerationName($name) { $enumeration = new Enumeration(); $db = Zend_Registry::get('dbAdapter'); $enumSelect = $db->select()->from($enumeration->_table)->where('parentId = (select enumerationId from enumerations where name=' . $db->quote($name) . ')'); $iter = $enumeration->getIterator($enumSelect); return $iter; }
public function getAllAncestors($enumerationId, $depth = null) { $db = Zend_Registry::get("dbAdapter"); $dbSelect = $db->select()->from(array("e" => "enumerations"))->join(array("ec" => $this->_table), "e.enumerationId = ec.ancestor", array())->where('e.active = 1')->where("ec.descendant = ?", (int) $enumerationId)->order("e.name ASC"); if ($depth !== null) { $dbSelect->where("ec.depth = ?", (int) $depth); } //trigger_error($dbSelect,E_USER_NOTICE); $enumeration = new Enumeration(); return $enumeration->getIterator($dbSelect); }
public static function getAllEnums($match, $parentId = 0) { $db = Zend_Registry::get('dbAdapter'); $enumeration = new Enumeration(); $enumerationsClosure = new EnumerationsClosure(); $whrSelect = $db->select()->from(array('cc' => $enumerationsClosure->_table), 'cc.descendant')->where('cc.ancestor != cc.descendant')->where('cc.descendant = c.ancestor'); $sqlSelect = $db->select()->from(array('e' => $enumeration->_table))->join(array('c' => $enumerationsClosure->_table), 'e.enumerationId = c.ancestor', array())->where('e.name LIKE ?', $match . '%')->where('c.ancestor = c.descendant')->where('c.depth = 0')->where('c.ancestor NOT IN ?', $whrSelect)->order('c.weight ASC'); if ($parentId > 0) { $sqlSelect->where('c.ancestor = ?', (int) $parentId); } //trigger_error($sqlSelect->__toString(),E_USER_NOTICE); return $enumeration->getIterator($sqlSelect); }