Esempio n. 1
0
 function toDialectString(IDialect $dialect)
 {
     //
     // FIXME move to IDialect
     //
     return 'DROP INDEX ' . $dialect->quoteIdentifier($this->index->getName()) . ($dialect->getDBDriver()->is(DBDriver::MYSQL) ? ' ON ' . $dialect->quoteIdentifier($this->index->getTable()->getName()) : '') . ($dialect->getDBDriver()->is(DBDriver::PGSQL) ? ' CASCADE ' : '') . ';';
 }
 function toDialectString(IDialect $dialect)
 {
     $value = $this->getValue();
     if (!is_null($value)) {
         return $dialect->quoteValue($dialect->getSqlBooleanValue($value));
     }
     return parent::toDialectString($dialect);
 }
Esempio n. 3
0
 function toDialectString(IDialect $dialect)
 {
     $processedPathChunks = array();
     foreach ($this->path as $pathChunk) {
         $processedPathChunks[] = $dialect->quoteIdentifier($pathChunk);
     }
     return join('.', $processedPathChunks);
 }
Esempio n. 4
0
 function toDialectString(IDialect $dialect)
 {
     $quotedFields = array();
     foreach ($this->getList() as $field) {
         $quotedFields[] = $dialect->quoteIdentifier($field);
     }
     $joinedFields = join(', ', $quotedFields);
     return $joinedFields;
 }
Esempio n. 5
0
 function toDialectString(IDialect $dialect)
 {
     $fieldValueCompiledPairs = array();
     foreach ($this->toArray() as $field => $value) {
         $fieldValueCompiledPairs[] = $dialect->quoteIdentifier($field) . '=' . $value->toDialectString($dialect);
     }
     $compiledCollection = join(', ', $fieldValueCompiledPairs);
     return $compiledCollection;
 }
Esempio n. 6
0
 function toDialectString(IDialect $dialect)
 {
     $sqlSlices = array();
     if ($this->table) {
         $sqlSlices[] = $dialect->quoteIdentifier($this->table);
     }
     $sqlSlices[] = $dialect->quoteIdentifier($this->field);
     $identifier = join('.', $sqlSlices);
     return $identifier;
 }
Esempio n. 7
0
 function toDialectString(IDialect $dialect)
 {
     $querySlices = array();
     $querySlices[] = 'DELETE FROM';
     $querySlices[] = $dialect->quoteIdentifier($this->table);
     if ($this->condition) {
         $querySlices[] = 'WHERE';
         $querySlices[] = $this->condition->toDialectString($dialect);
     }
     $compiledQuery = join(' ', $querySlices);
     return $compiledQuery;
 }
 function toDialectString(IDialect $dialect)
 {
     $queryParts = array();
     $this->commaSeparatedQueryParts = array();
     $queryParts[] = 'CREATE TABLE ';
     $queryParts[] = $dialect->quoteIdentifier($this->table->getName());
     $queryParts[] = '(';
     $this->makeColumns($dialect);
     $queryParts[] = join(',', $this->commaSeparatedQueryParts);
     $queryParts[] = StringUtils::DELIM_STANDART;
     $queryParts[] = ');';
     return join('', $queryParts);
 }
    /**
     * Dumps schema
     *
     * @param IOutput $writeStream stream to write the dump to
     * @param IDialect $dialect database dialect to use
     *
     * @return void
     */
    function make(IOutput $writeStream, IDialect $dialect)
    {
        $now = date('Y/m/d H:i');
        $product = PHOEBIUS_FULL_PRODUCT_NAME;
        $start = <<<EOT
--
-- {$product}
-- Generated at {$now} for {$dialect->getDBDriver()->getValue()}
--


EOT;
        $writeStream->write($start)->write($this->dbSchema->toDialectString($dialect));
    }
Esempio n. 10
0
 function toDialectString(IDialect $dialect)
 {
     $querySlices = array();
     $querySlices[] = 'INSERT INTO';
     $querySlices[] = $dialect->quoteIdentifier($this->tableName);
     $querySlices[] = '(';
     $querySlices[] = $this->getCompiledFields($dialect);
     $querySlices[] = ')';
     $querySlices[] = 'VALUES';
     $querySlices[] = '(';
     $querySlices[] = $this->getCompiledValues($dialect);
     $querySlices[] = ')';
     $compiledQuery = join(' ', $querySlices);
     return $compiledQuery;
 }
 function toDialectString(IDialect $dialect)
 {
     $table = $dialect->quoteIdentifier($this->constraint->getTable()->getName());
     $ct = $dialect->quoteIdentifier($this->constraint->getName());
     if ($dialect->getDBDriver()->is(DBDriver::MYSQL)) {
         if ($this->constraint instanceof DBUniqueConstraint) {
             return 'ALTER TABLE ' . $table . ' DROP INDEX ' . $ct;
         } else {
             if ($this->constraint instanceof DBPrimaryKeyConstraint) {
                 return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY';
             } else {
                 if ($this->constraint instanceof DBOneToOneConstraint || $this->constraint instanceof DBForeignKeyConstraint) {
                     return 'ALTER TABLE ' . $table . ' DROP FOREIGN KEY ' . $ct;
                 }
             }
         }
         Assert::isUnreachable('Do not know how to remove constraint %s from MySQL', get_class($this->constraint));
     }
     return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $ct . ' CASCADE;';
 }
Esempio n. 12
0
 /**
  * Gets the SQL representation of the constraint's head
  *
  * @param IDialect $dialect
  *
  * @return string
  */
 protected function getHead(IDialect $dialect)
 {
     return 'CONSTRAINT ' . $dialect->quoteIdentifier($this->name);
 }
Esempio n. 13
0
 function toDialectString(IDialect $dialect)
 {
     $queryParts[] = $dialect->quoteIdentifier($this->name);
     $queryParts[] = ' ';
     $queryParts[] = $this->type->toDialectString($dialect);
     if ($this->defaultValue) {
         $queryParts[] = ' DEFAULT ';
         $queryParts[] = $this->defaultValue->toDialectString($dialect);
     }
     $string = join('', $queryParts);
     return $string;
 }
Esempio n. 14
0
 function toDialectString(IDialect $dialect)
 {
     return $dialect->getTypeRepresentation($this);
 }
 function toDialectString(IDialect $dialect)
 {
     return 'ALTER TABLE ' . $dialect->quoteIdentifier($this->column->getTable()->getName()) . ' ADD COLUMN ' . $this->column->toDialectString($dialect) . ';';
 }
Esempio n. 16
0
 function toDialectString(IDialect $dialect)
 {
     return $dialect->quoteIdentifier($this->id);
 }
Esempio n. 17
0
 /**
  * Creates a list of ISqlQuery objects that represent a DDL for the table
  *
  * @param IDialect $dialect database dialect to use
  * @return array of ISqlQuery
  */
 function toQueries(IDialect $dialect)
 {
     return $dialect->getTableQuerySet($this, true);
 }
Esempio n. 18
0
 function toDialectString(IDialect $dialect)
 {
     return $dialect->quoteValue($this->value);
 }
Esempio n. 19
0
 function toDialectString(IDialect $dialect)
 {
     return 'INDEX ' . $dialect->quoteIdentifier($this->name) . ' ON ' . $dialect->quoteIdentifier($this->table->getName()) . ' (' . $this->getFieldsAsString($dialect) . ')';
 }
Esempio n. 20
0
 function toDialectString(IDialect $dialect)
 {
     // tables
     // columns
     // constraints
     // indexes
     $yield = array();
     foreach ($this->dropIndexes as $index) {
         $yield[] = new DropIndexQuery($index);
     }
     foreach ($this->dropConstraints as $constraint) {
         $yield[] = new DropConstraintQuery($constraint);
     }
     foreach ($this->dropColumns as $column) {
         $yield[] = new DropColumnQuery($column);
     }
     foreach ($this->dropTables as $table) {
         $yield[] = new DropTableQuery($table);
     }
     foreach ($this->createTables as $table) {
         $yield[] = new CreateTableQuery($table);
     }
     foreach ($this->createColumns as $column) {
         $yield[] = new CreateColumnQuery($column);
     }
     foreach ($this->createConstraints as $constraint) {
         $yield[] = new CreateConstraintQuery($constraint);
         foreach ($this->createTables as $table) {
             foreach ($table->getConstraintQueries() as $query) {
                 $yield[] = $query;
             }
         }
     }
     foreach ($this->createIndexes as $index) {
         $yield[] = new CreateIndexQuery($index);
         foreach ($this->createTables as $table) {
             foreach ($table->getIndexQueries() as $query) {
                 $yield[] = $query;
             }
         }
     }
     foreach ($this->createTables as $table) {
         foreach ($dialect->getExtraTableQueries($table) as $query) {
             $yield[] = $query;
         }
     }
     $set = new SqlQuerySet($yield);
     return $set->toDialectString($dialect);
 }
Esempio n. 21
0
 function toDialectString(IDialect $dialect)
 {
     return 'DROP TABLE ' . $dialect->quoteIdentifier($this->table->getName()) . ' CASCADE;';
 }
 function toDialectString(IDialect $dialect)
 {
     return 'ALTER TABLE ' . $dialect->quoteIdentifier($this->table->getName()) . ' ADD ' . $this->constraint->toDialectString($dialect) . ';';
 }