/** * Construct the sql used to do a find() method * * @param array $options * @return string the SQL */ protected function _constructFinderSql($options) { $valid = array('select', 'from', 'conditions', 'include', 'order', 'group', 'limit', 'offset'); $options = Mad_Support_Base::assertValidKeys($options, $valid); $sql = "SELECT " . ($options['select'] ? $options['select'] : $this->getColumnStr()); $sql .= " FROM " . ($options['from'] ? $options['from'] : $this->tableName()); $sql = $this->_addConditions($sql, $options['conditions']); if ($options['group']) { $sql .= ' GROUP BY ' . $options['group']; } if ($options['order']) { $sql .= ' ORDER BY ' . $options['order']; } return $this->connection->addLimitOffset($sql, $options); }