protected function appendIndexes() { foreach ($this->table->indexes as $index) { $columns = Symbol::prepareColumns($index->columns); if ($index->type === Index::TYPE_KEY) { $createIndex = new SimpleExpression("CREATE INDEX ? ON ? (?)", new Symbol($index->getName()), new Symbol($this->table->schemaName), $columns); $createIndex->bindDatabase($this->database()); $this->add($createIndex); //$this->appendExpr(' KEY ? (?),' . PHP_EOL, new Symbol($index->getName()), $columns); } elseif ($index->type === Index::TYPE_UNIQUE) { $this->createLines->commaExpr(' CONSTRAINT ? UNIQUE (?)', new Symbol($index->getName()), $columns); } } }
public function expr($expression, $binds = null) { $e = SimpleExpression::createFromFuncArguments(func_get_args()); return $e; }
public function generateDropTable($tableName) { return SimpleExpression::create("DROP TABLE ?", new Symbol($tableName))->bindDatabase($this->database); }
public function prependExpr($expression) { array_unshift($this->queue, array(self::OP_APPEND, SimpleExpression::createFromFuncArguments(func_get_args()))); return $this; }
/** * @param $expression * @param null $binds * @return SimpleExpression * @throws Sql\Exception */ public function expr($expression = null, $binds = null) { return SimpleExpression::createFromFuncArguments(func_get_args())->bindDatabase($this); }
/** * @return string * @throws Exception */ public function build() { return $this->expression->build($this->driver); }
public function extractForeignKeysStatement() { $alterExpression = new SimpleExpression('ALTER TABLE ?' . PHP_EOL, new Symbol($this->after->schemaName)); $alterExpression->bindDatabase($this->database()); $alterExpression->appendExpr(clone $this->addFkExpression); $this->addFkExpression->disable(); return $alterExpression; }
public function set($expression, $binds = null) { if (null === $expression) { return $this; } if (is_array($expression)) { $expressionString = ''; $bindsArray = array(); if (is_string($binds)) { $table = $binds; } else { $table = null; } foreach ($expression as $key => $value) { $expressionString .= '? = ?, '; $bindsArray[] = new Symbol($table, $key); $bindsArray[] = $value; } $expressionString = substr($expressionString, 0, -2); $expression = new SimpleExpression($expressionString, $bindsArray); } else { $expression = SimpleExpression::createFromFuncArguments(func_get_args()); } if (null === $this->set) { $this->set = $expression; } else { $this->set->commaExpr($expression); } return $this; }