db->select(); $select->from(array($this->_getTableName($tableAlias, $isService)), $columns); if (null != $where) { $where = (array) $where; foreach ($where as $_where) { $select->where($_where); } } if (null === $order) { // automatic order initialization $meta = $this->_getTable($tableAlias, $isService)->info(Zend_Db_Table::METADATA); if (array_key_exists('enabled', $meta)) { $select->where('`enabled` = "y"'); } if (array_key_exists('sorter', $meta)) { $order = 'sorter'; } elseif ('*' == $columns) { $primary = $this->_getTable($tableAlias, $isService)->info(Zend_Db_Table::PRIMARY); $fields = Qs_Array::excludeArray($meta, $primary); $order = key($fields); } elseif (is_array($columns)) { $order = next($columns); } } if ($order) { // use $order = false to disable automatic initialization $select->order($order); } if (null != $limit) { $select->limit($limit); } if (is_array($columns) && count($columns) > 2) { return $this->db->fetchAssoc($select); } return $this->db->fetchPairs($select); } }