当前位置: 首页>>代码示例>>PHP>>正文


PHP Schema::getTable方法代码示例

本文整理汇总了PHP中Schema::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::getTable方法的具体用法?PHP Schema::getTable怎么用?PHP Schema::getTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schema的用法示例。


在下文中一共展示了Schema::getTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compare

 /**
  * Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
  *
  * The returned differences are returned in such a way that they contain the
  * operations to change the schema stored in $fromSchema to the schema that is
  * stored in $toSchema.
  *
  * @param Schema $fromSchema
  * @param Schema $toSchema
  *
  * @return SchemaDiff
  */
 public function compare(Schema $fromSchema, Schema $toSchema)
 {
     $diff = new SchemaDiff();
     $foreignKeysToTable = array();
     foreach ($toSchema->getTables() as $table) {
         $tableName = $table->getShortestName($toSchema->getName());
         if (!$fromSchema->hasTable($tableName)) {
             $diff->newTables[$tableName] = $toSchema->getTable($tableName);
         } else {
             $tableDifferences = $this->diffTable($fromSchema->getTable($tableName), $toSchema->getTable($tableName));
             if ($tableDifferences !== false) {
                 $diff->changedTables[$tableName] = $tableDifferences;
             }
         }
     }
     /* Check if there are tables removed */
     foreach ($fromSchema->getTables() as $table) {
         $tableName = $table->getShortestName($fromSchema->getName());
         $table = $fromSchema->getTable($tableName);
         if (!$toSchema->hasTable($tableName)) {
             $diff->removedTables[$tableName] = $table;
         }
         // also remember all foreign keys that point to a specific table
         foreach ($table->getForeignKeys() as $foreignKey) {
             $foreignTable = strtolower($foreignKey->getForeignTableName());
             if (!isset($foreignKeysToTable[$foreignTable])) {
                 $foreignKeysToTable[$foreignTable] = array();
             }
             $foreignKeysToTable[$foreignTable][] = $foreignKey;
         }
     }
     foreach ($diff->removedTables as $tableName => $table) {
         if (isset($foreignKeysToTable[$tableName])) {
             $diff->orphanedForeignKeys = array_merge($diff->orphanedForeignKeys, $foreignKeysToTable[$tableName]);
         }
     }
     foreach ($toSchema->getSequences() as $sequence) {
         $sequenceName = $sequence->getShortestName($toSchema->getName());
         if (!$fromSchema->hasSequence($sequenceName)) {
             $diff->newSequences[] = $sequence;
         } else {
             if ($this->diffSequence($sequence, $fromSchema->getSequence($sequenceName))) {
                 $diff->changedSequences[] = $toSchema->getSequence($sequenceName);
             }
         }
     }
     foreach ($fromSchema->getSequences() as $sequence) {
         if ($this->isAutoIncrementSequenceInSchema($toSchema, $sequence)) {
             continue;
         }
         $sequenceName = $sequence->getShortestName($fromSchema->getName());
         if (!$toSchema->hasSequence($sequenceName)) {
             $diff->removedSequences[] = $sequence;
         }
     }
     return $diff;
 }
开发者ID:ashimidashajia,项目名称:zendstore,代码行数:69,代码来源:Comparator.php

示例2: buildGetDataSQL

 /**
  * Builds the SQL statement to select the data for this page and schema
  *
  * @return array Two fields: the SQL string and the parameters array
  */
 protected function buildGetDataSQL()
 {
     $sep = Search::CONCAT_SEPARATOR;
     $stable = 'data_' . $this->schema->getTable();
     $mtable = 'multi_' . $this->schema->getTable();
     $QB = new QueryBuilder();
     $QB->addTable($stable, 'DATA');
     $QB->addSelectColumn('DATA', 'pid', 'PID');
     $QB->addGroupByStatement('DATA.pid');
     foreach ($this->schema->getColumns(false) as $col) {
         $colref = $col->getColref();
         $colname = 'col' . $colref;
         $outname = 'out' . $colref;
         if ($col->getType()->isMulti()) {
             $tn = 'M' . $colref;
             $QB->addLeftJoin('DATA', $mtable, $tn, "DATA.pid = {$tn}.pid AND DATA.rev = {$tn}.rev AND {$tn}.colref = {$colref}");
             $col->getType()->select($QB, $tn, 'value', $outname);
             $sel = $QB->getSelectStatement($outname);
             $QB->addSelectStatement("GROUP_CONCAT({$sel}, '{$sep}')", $outname);
         } else {
             $col->getType()->select($QB, 'DATA', $colname, $outname);
             $QB->addGroupByStatement($outname);
         }
     }
     $pl = $QB->addValue($this->pid);
     $QB->filters()->whereAnd("DATA.pid = {$pl}");
     $pl = $QB->addValue($this->getLastRevisionTimestamp());
     $QB->filters()->whereAnd("DATA.rev = {$pl}");
     return $QB->getSQL();
 }
开发者ID:cosmocode,项目名称:dokuwiki-plugin-struct,代码行数:35,代码来源:AccessTable.php

示例3: compare

 /**
  * Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
  *
  * The returned diferences are returned in such a way that they contain the
  * operations to change the schema stored in $fromSchema to the schema that is
  * stored in $toSchema.
  *
  * @param Schema $fromSchema
  * @param Schema $toSchema
  *
  * @return SchemaDiff
  */
 public function compare(Schema $fromSchema, Schema $toSchema)
 {
     if ($fromSchema->hasExplicitForeignKeyIndexes() && !$toSchema->hasExplicitForeignKeyIndexes()) {
         $toSchema->visit(new \Doctrine\DBAL\Schema\Visitor\FixSchema(true));
     }
     $diff = new SchemaDiff();
     $foreignKeysToTable = array();
     foreach ($toSchema->getTables() as $tableName => $table) {
         if (!$fromSchema->hasTable($tableName)) {
             $diff->newTables[$tableName] = $table;
         } else {
             $tableDifferences = $this->diffTable($fromSchema->getTable($tableName), $table);
             if ($tableDifferences !== false) {
                 $diff->changedTables[$tableName] = $tableDifferences;
             }
         }
     }
     /* Check if there are tables removed */
     foreach ($fromSchema->getTables() as $tableName => $table) {
         if (!$toSchema->hasTable($tableName)) {
             $diff->removedTables[$tableName] = $table;
         }
         // also remember all foreign keys that point to a specific table
         foreach ($table->getForeignKeys() as $foreignKey) {
             $foreignTable = strtolower($foreignKey->getForeignTableName());
             if (!isset($foreignKeysToTable[$foreignTable])) {
                 $foreignKeysToTable[$foreignTable] = array();
             }
             $foreignKeysToTable[$foreignTable][] = $foreignKey;
         }
     }
     foreach ($diff->removedTables as $tableName => $table) {
         if (isset($foreignKeysToTable[$tableName])) {
             $diff->orphanedForeignKeys = array_merge($diff->orphanedForeignKeys, $foreignKeysToTable[$tableName]);
         }
     }
     foreach ($toSchema->getSequences() as $sequenceName => $sequence) {
         if (!$fromSchema->hasSequence($sequenceName)) {
             $diff->newSequences[] = $sequence;
         } else {
             if ($this->diffSequence($sequence, $fromSchema->getSequence($sequenceName))) {
                 $diff->changedSequences[] = $fromSchema->getSequence($sequenceName);
             }
         }
     }
     foreach ($fromSchema->getSequences() as $sequenceName => $sequence) {
         if (!$toSchema->hasSequence($sequenceName)) {
             $diff->removedSequences[] = $sequence;
         }
     }
     return $diff;
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:64,代码来源:Comparator.php

示例4: compare

 /**
  * Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
  *
  * The returned differences are returned in such a way that they contain the
  * operations to change the schema stored in $fromSchema to the schema that is
  * stored in $toSchema.
  *
  * @param \Doctrine\DBAL\Schema\Schema $fromSchema
  * @param \Doctrine\DBAL\Schema\Schema $toSchema
  *
  * @return \Doctrine\DBAL\Schema\SchemaDiff
  */
 public function compare(Schema $fromSchema, Schema $toSchema)
 {
     $diff = new SchemaDiff();
     $diff->fromSchema = $fromSchema;
     $foreignKeysToTable = array();
     foreach ($toSchema->getTables() as $table) {
         $tableName = $table->getShortestName($toSchema->getName());
         if (!$fromSchema->hasTable($tableName)) {
             $diff->newTables[$tableName] = $toSchema->getTable($tableName);
         } else {
             $tableDifferences = $this->diffTable($fromSchema->getTable($tableName), $toSchema->getTable($tableName));
             if ($tableDifferences !== false) {
                 $diff->changedTables[$tableName] = $tableDifferences;
             }
         }
     }
     /* Check if there are tables removed */
     foreach ($fromSchema->getTables() as $table) {
         $tableName = $table->getShortestName($fromSchema->getName());
         $table = $fromSchema->getTable($tableName);
         if (!$toSchema->hasTable($tableName)) {
             $diff->removedTables[$tableName] = $table;
         }
         // also remember all foreign keys that point to a specific table
         foreach ($table->getForeignKeys() as $foreignKey) {
             $foreignTable = strtolower($foreignKey->getForeignTableName());
             if (!isset($foreignKeysToTable[$foreignTable])) {
                 $foreignKeysToTable[$foreignTable] = array();
             }
             $foreignKeysToTable[$foreignTable][] = $foreignKey;
         }
     }
     foreach ($diff->removedTables as $tableName => $table) {
         if (isset($foreignKeysToTable[$tableName])) {
             $diff->orphanedForeignKeys = array_merge($diff->orphanedForeignKeys, $foreignKeysToTable[$tableName]);
             // deleting duplicated foreign keys present on both on the orphanedForeignKey
             // and the removedForeignKeys from changedTables
             foreach ($foreignKeysToTable[$tableName] as $foreignKey) {
                 // strtolower the table name to make if compatible with getShortestName
                 $localTableName = strtolower($foreignKey->getLocalTableName());
                 if (isset($diff->changedTables[$localTableName])) {
                     foreach ($diff->changedTables[$localTableName]->removedForeignKeys as $key => $removedForeignKey) {
                         unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]);
                     }
                 }
             }
         }
     }
     foreach ($toSchema->getSequences() as $sequence) {
         $sequenceName = $sequence->getShortestName($toSchema->getName());
         if (!$fromSchema->hasSequence($sequenceName)) {
             $diff->newSequences[] = $sequence;
         } else {
             if ($this->diffSequence($sequence, $fromSchema->getSequence($sequenceName))) {
                 $diff->changedSequences[] = $toSchema->getSequence($sequenceName);
             }
         }
     }
     foreach ($fromSchema->getSequences() as $sequence) {
         if ($this->isAutoIncrementSequenceInSchema($toSchema, $sequence)) {
             continue;
         }
         $sequenceName = $sequence->getShortestName($fromSchema->getName());
         if (!$toSchema->hasSequence($sequenceName)) {
             $diff->removedSequences[] = $sequence;
         }
     }
     return $diff;
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:81,代码来源:Comparator.php


注:本文中的Schema::getTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。