當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Table::getName方法代碼示例

本文整理匯總了PHP中Phinx\Db\Table::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::getName方法的具體用法?PHP Table::getName怎麽用?PHP Table::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phinx\Db\Table的用法示例。


在下文中一共展示了Table::getName方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate

 /**
  * @throws \RuntimeException
  */
 protected function validate()
 {
     if ($this->adapter->hasTable($this->origin->getName()) && $this->adapter->hasTable($this->destination->getName())) {
         return;
     }
     throw new \RuntimeException("Table `{$this->origin->getName()}` and `{$this->destination->getName()}` must exist.");
 }
開發者ID:tristanpemble,項目名稱:lhm_php,代碼行數:10,代碼來源:AtomicSwitcher.php

示例2: extractPrimaryKey

 /**
  * Extract the primary key of a table.
  *
  * @param \Phinx\Db\Table $table
  * @return string
  */
 public function extractPrimaryKey(\Phinx\Db\Table $table)
 {
     $tableName = $table->getName();
     $databaseName = $this->adapter->getOption('name');
     $query = implode(" ", ['SELECT `COLUMN_NAME`', 'FROM `information_schema`.`COLUMNS`', "WHERE (`TABLE_SCHEMA` = '{$databaseName}')", "AND (`TABLE_NAME` = '{$tableName}')", "AND (`COLUMN_KEY` = 'PRI');"]);
     $result = $this->adapter->query($query);
     if ($result instanceof \PDOStatement) {
         return $result->fetchColumn(0);
     }
     if (is_array($result)) {
         return $result[0];
     }
     return $result;
 }
開發者ID:tristanpemble,項目名稱:lhm_php,代碼行數:20,代碼來源:SqlHelper.php

示例3: addForeignKey

 /**
  * {@inheritdoc}
  */
 public function addForeignKey(Table $table, ForeignKey $foreignKey)
 {
     $this->startCommandTimer();
     $this->writeCommand('addForeignKey', array($table->getName(), $foreignKey->getColumns()));
     $this->execute(sprintf('ALTER TABLE %s ADD %s', $this->quoteTableName($table->getName()), $this->getForeignKeySqlDefinition($foreignKey, $table->getName())));
     $this->endCommandTimer();
 }
開發者ID:lhas,項目名稱:pep,代碼行數:10,代碼來源:SqlServerAdapter.php

示例4: addForeignKey

 /**
  * {@inheritdoc}
  */
 public function addForeignKey(Table $table, ForeignKey $foreignKey)
 {
     $adapterTable = clone $table;
     $adapterTableName = $this->getAdapterTableName($table->getName());
     $adapterTable->setName($adapterTableName);
     return parent::addForeignKey($adapterTable, $foreignKey);
 }
開發者ID:elliotwms,項目名稱:phinx,代碼行數:10,代碼來源:TablePrefixAdapter.php

示例5: insert

 /**
  * {@inheritdoc}
  */
 public function insert(Table $table, $columns, $data)
 {
     $this->startCommandTimer();
     $sql = sprintf("INSERT INTO %s ", $this->quoteTableName($table->getName()));
     $sql .= "(" . implode(', ', array_map(array($this, 'quoteColumnName'), $columns)) . ")";
     $sql .= " VALUES (" . implode(', ', array_fill(0, count($columns), '?')) . ")";
     $stmt = $this->getConnection()->prepare($sql);
     foreach ($data as $row) {
         $stmt->execute($row);
     }
     $this->endCommandTimer();
 }
開發者ID:secteofilandia,項目名稱:ieducar,代碼行數:15,代碼來源:PdoAdapter.php

示例6: getIndexSqlDefinition

 /**
  * Gets the SQLite Index Definition for an Index object.
  *
  * @param Index $index Index
  * @return string
  */
 protected function getIndexSqlDefinition(Table $table, Index $index)
 {
     if ($index->getType() == Index::UNIQUE) {
         $def = 'UNIQUE INDEX';
     } else {
         $def = 'INDEX';
     }
     if (is_string($index->getName())) {
         $indexName = $index->getName();
     } else {
         $indexName = $table->getName() . '_';
         foreach ($index->getColumns() as $column) {
             $indexName .= $column . '_';
         }
         $indexName .= 'index';
     }
     $def .= ' `' . $indexName . '`';
     return $def;
 }
開發者ID:elliotwms,項目名稱:phinx,代碼行數:25,代碼來源:SQLiteAdapter.php

示例7: insert

 /**
  * {@inheritdoc}
  */
 public function insert(Table $table, $row)
 {
     $adapterTable = clone $table;
     $adapterTableName = $this->getAdapterTableName($table->getName());
     $adapterTable->setName($adapterTableName);
     return parent::insert($adapterTable, $row);
 }
開發者ID:stephenorr,項目名稱:phinx,代碼行數:10,代碼來源:TablePrefixAdapter.php

示例8: testAddTableWithForeignKey

 public function testAddTableWithForeignKey()
 {
     $this->mock->expects($this->any())->method('isValidColumnType')->with($this->callback(function ($column) {
         return in_array($column->getType(), array('string', 'integer'));
     }))->will($this->returnValue(true));
     $table = new Table('table', array(), $this->adapter);
     $table->addColumn('bar', 'string')->addColumn('relation', 'integer')->addForeignKey('relation', 'target_table', array('id'));
     $this->mock->expects($this->once())->method('createTable')->with($this->callback(function ($table) {
         if ($table->getName() !== 'pre_table_suf') {
             throw new \Exception(sprintf('Table::getName was not prefixed/suffixed properly: "%s"', $table->getName()));
         }
         $fks = $table->getForeignKeys();
         if (count($fks) !== 1) {
             throw new \Exception(sprintf('Table::getForeignKeys count was incorrect: %d', count($fks)));
         }
         foreach ($fks as $fk) {
             if ($fk->getReferencedTable()->getName() !== 'pre_target_table_suf') {
                 throw new \Exception(sprintf('ForeignKey::getReferencedTable was not prefixed/suffixed properly: "%s"', $fk->getReferencedTable->getName()));
             }
         }
         return true;
     }));
     $table->create();
 }
開發者ID:stephenorr,項目名稱:phinx,代碼行數:24,代碼來源:TablePrefixAdapterTest.php

示例9: createTable

 /**
  * {@inheritdoc}
  */
 public function createTable(Table $table)
 {
     $this->recordCommand('createTable', array($table->getName()));
 }
開發者ID:a53ali,項目名稱:CakePhP,代碼行數:7,代碼來源:ProxyAdapter.php

示例10: addForeignKey

 /**
  * {@inheritdoc}
  */
 public function addForeignKey(Table $table, ForeignKey $foreignKey)
 {
     // TODO: DRY this up....
     $this->startCommandTimer();
     $this->writeCommand('addForeignKey', array($table->getName(), $foreignKey->getColumns()));
     $this->execute('pragma foreign_keys = ON');
     $tmpTableName = 'tmp_' . $table->getName();
     $rows = $this->fetchAll('select * from sqlite_master where `type` = \'table\'');
     $sql = '';
     foreach ($rows as $row) {
         if ($row['tbl_name'] == $table->getName()) {
             $sql = $row['sql'];
         }
     }
     $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($table->getName())));
     $columns = array();
     foreach ($columns as $column) {
         $columns[] = $this->quoteColumnName($column['name']);
     }
     $this->execute(sprintf('ALTER TABLE %s RENAME TO %s', $this->quoteTableName($table->getName()), $tmpTableName));
     $sql = substr($sql, 0, -1) . ',' . $this->getForeignKeySqlDefinition($foreignKey) . ')';
     $this->execute($sql);
     $sql = sprintf('INSERT INTO %s(%s) SELECT %s FROM %s', $table->getName(), implode(', ', $columns), implode(', ', $columns), $tmpTableName);
     $this->execute($sql);
     $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tmpTableName)));
     $this->endCommandTimer();
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:30,代碼來源:SQLiteAdapter.php

示例11: testItRenamesDestinationToOrigin

 public function testItRenamesDestinationToOrigin()
 {
     $this->assertTrue($this->adapter->hasTable($this->destination->getName()));
     $this->switcher->run();
     $this->assertFalse($this->adapter->hasTable($this->destination->getName()));
 }
開發者ID:tristanpemble,項目名稱:lhm_php,代碼行數:6,代碼來源:AtomicSwitcherTest.php

示例12: getName

 /**
  * Gets the table name.
  *
  * @return string
  */
 public function getName()
 {
     return $this->table->getName();
 }
開發者ID:nilopc-interesting-libs,項目名稱:sql-schema-builder,代碼行數:9,代碼來源:Table.php


注:本文中的Phinx\Db\Table::getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。