/** * Returns the indexes on this data definition * * @return \Slick\Database\Query\Ddl\Utility\ElementList An Index list * * @see Slick\Database\Query\Ddl\Utility::Index */ public function getIndexes() { $indexes = new ElementList(); foreach ($this->_data as $row) { if ($row['type'] == 'index') { $index = new Index(array('name' => $row['name'])); $indexes->append($index); if (strpos($row['sql'], 'UNIQUE') !== false) { $index->setType(Index::UNIQUE); } if (preg_match('/\\((?P<names>.*)\\)/i', $row['sql'], $matches)) { $fields = str_replace(array(' ASC', ' DESC'), '', $matches['names']); $index->indexColumns = ArrayMethods::clean(explode(',', $fields)); } } } return $indexes; }
/** * Returns all columns, index and constraints definitions * * @return string SQL for columns, indexes and constraints */ public function getDefinitions() { $parts = array($this->_getColumns(), $this->_getChangedColumns(), $this->_getDroppedColumns(), $this->_getIndexes(), $this->_getDroppedIndexes(), $this->_getConstraints(), $this->_getDroppedConstraints(), $this->getOptions()); $parts = ArrayMethods::clean($parts); return implode(",\n", $parts); }
/** * Checks if a sql string contains multiple statements * * @param string $sql The query string * * @return boolean True if has multiple statements */ protected function _isMultiple($sql) { $sql = trim(trim($sql, ';')); $statements = explode(';', $sql); if (sizeof($statements) > 1) { $this->_sql = ArrayMethods::trim($statements); return true; } return false; }