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


PHP Table::getColumn方法代码示例

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


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

示例1: addUniqueConstraint

 /**
  * Adds a unique constraint to the table to enforce uniqueness of the slug_column
  *
  * @param Table $table
  */
 protected function addUniqueConstraint(Table $table)
 {
     $unique = new Unique($this->getColumnForParameter('slug_column'));
     $unique->setName($table->getCommonName() . '_slug');
     $unique->addColumn($table->getColumn($this->getParameter('slug_column')));
     if ($this->getParameter('scope_column')) {
         $unique->addColumn($table->getColumn($this->getParameter('scope_column')));
     }
     $table->addUnique($unique);
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:15,代码来源:SluggableBehavior.php

示例2: addClosureColumn

 protected function addClosureColumn($name, Table $ct_table, Column $column)
 {
     $table = $this->getTable();
     $id_fieldname = $column->getName();
     $domain = $column->getDomain();
     if (!$ct_table->hasColumn($name)) {
         $column = new Column($name);
         $column->setDomain($domain);
         $column->setPrimaryKey(true);
         $ct_table->addColumn($column);
     } else {
         $column = $ct_table->getColumn($name);
     }
     $ct_tablename_normalized = str_replace('_', '', $ct_table->getName());
     $fk_name = $ct_tablename_normalized . '_' . $name . '_fk';
     if (!$ct_table->getColumnForeignKeys($name)) {
         $column_fk = new ForeignKey($fk_name);
         $column_fk->addReference($name, $table->getColumn($id_fieldname)->getName());
         $column_fk->setForeignTableCommonName($table->getName());
         $column_fk->setOnUpdate('cascade');
         $column_fk->setOnDelete('restrict');
         $ct_table->addForeignKey($column_fk);
     }
     $column_idx_name = $fk_name . '_idx';
     if (!$ct_table->hasIndex($column_idx_name)) {
         $column_idx = new Index($column_idx_name);
         $column_idx->addColumn(['name' => $column->getName()]);
         $ct_table->addIndex($column_idx);
     }
 }
开发者ID:scif,项目名称:propel-closuretable-behavior,代码行数:30,代码来源:ClosureTableBehavior.php

示例3: isAtLeastOneLocalColumnRequired

 /**
  * Returns whether this foreign key uses at least one required local column.
  *
  * @return boolean
  */
 public function isAtLeastOneLocalColumnRequired()
 {
     foreach ($this->localColumns as $columnName) {
         if ($this->parentTable->getColumn($columnName)->isNotNull()) {
             return true;
         }
     }
     return false;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:14,代码来源:ForeignKey.php

示例4: normalizeTable

 /**
  * Unfortunately, SQLite does not support composite pks where one is AUTOINCREMENT,
  * so we have to flag both as NOT NULL and create a UNIQUE constraint.
  *
  * @param Table $table
  */
 public function normalizeTable(Table $table)
 {
     if (count($pks = $table->getPrimaryKey()) > 1 && $table->hasAutoIncrementPrimaryKey()) {
         foreach ($pks as $pk) {
             //no pk can be NULL, as usual
             $pk->setNotNull(true);
             //in SQLite the column with the AUTOINCREMENT MUST be a primary key, too.
             if (!$pk->isAutoIncrement()) {
                 //for all other sub keys we remove it, since we create a UNIQUE constraint over all primary keys.
                 $pk->setPrimaryKey(false);
             }
         }
         //search if there is already a UNIQUE constraint over the primary keys
         $pkUniqueExist = false;
         foreach ($table->getUnices() as $unique) {
             $allPk = false;
             foreach ($unique->getColumns() as $columnName) {
                 $allPk &= $table->getColumn($columnName)->isPrimaryKey();
             }
             if ($allPk) {
                 //there's already a unique constraint with the composite pk
                 $pkUniqueExist = true;
                 break;
             }
         }
         //there is none, let's create it
         if (!$pkUniqueExist) {
             $unique = new Unique();
             foreach ($pks as $pk) {
                 $unique->addColumn($pk);
             }
             $table->addUnique($unique);
         }
     }
     parent::normalizeTable($table);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:42,代码来源:SqlitePlatform.php

示例5: addIndexes

 /**
  * Load indexes for this table
  */
 protected function addIndexes(Table $table)
 {
     $stmt = $this->dbh->query("PRAGMA index_list('" . $table->getName() . "')");
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $name = $row['name'];
         $index = new Index($name);
         $stmt2 = $this->dbh->query("PRAGMA index_info('" . $name . "')");
         while ($row2 = $stmt2->fetch(\PDO::FETCH_ASSOC)) {
             $colname = $row2['name'];
             $index->addColumn($table->getColumn($colname));
         }
         $table->addIndex($index);
     }
 }
开发者ID:robin850,项目名称:Propel2,代码行数:17,代码来源:SqliteSchemaParser.php

示例6: addIndexes

 /**
  * Load indexes for this table
  */
 protected function addIndexes(Table $table)
 {
     $stmt = $this->dbh->query('PRAGMA index_list("' . $table->getName() . '")');
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $name = $row['name'];
         $internalName = $name;
         if (0 === strpos($name, 'sqlite_autoindex')) {
             $internalName = '';
         }
         $index = $row['unique'] ? new Unique($internalName) : new Index($internalName);
         $stmt2 = $this->dbh->query("PRAGMA index_info('" . $name . "')");
         while ($row2 = $stmt2->fetch(\PDO::FETCH_ASSOC)) {
             $colname = $row2['name'];
             $index->addColumn($table->getColumn($colname));
         }
         if (1 === count($table->getPrimaryKey()) && 1 === count($index->getColumns())) {
             // exclude the primary unique index, since it's autogenerated by sqlite
             if ($table->getPrimaryKey()[0]->getName() === $index->getColumns()[0]) {
                 continue;
             }
         }
         if ($index instanceof Unique) {
             $table->addUnique($index);
         } else {
             $table->addIndex($index);
         }
     }
 }
开发者ID:KyleGoslan,项目名称:Huge-Propel,代码行数:31,代码来源:SqliteSchemaParser.php

示例7: testCantGetColumn

 public function testCantGetColumn()
 {
     $table = new Table('books');
     $this->assertFalse($table->hasColumn('FOO', true));
     $this->assertNull($table->getColumn('FOO'));
     $this->assertNull($table->getColumnByPhpName('Foo'));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:7,代码来源:TableTest.php

示例8: addPrimaryKey

 /**
  * Loads the primary key for this table.
  */
 protected function addPrimaryKey(Table $table)
 {
     $dataFetcher = $this->dbh->query("SELECT COLUMN_NAME\n            FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS\n            INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ON\n            INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.constraint_name\n            WHERE     (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'PRIMARY KEY') AND\n            (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '" . $table->getName() . "')");
     // Loop through the returned results, grouping the same key_name together
     // adding each column for that key.
     foreach ($dataFetcher as $row) {
         $name = $this->cleanDelimitedIdentifiers($row[0]);
         $table->getColumn($name)->setPrimaryKey(true);
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:13,代码来源:MssqlSchemaParser.php

示例9: addPrimaryKey

 /**
  * Loads the primary key for this table.
  *
  * @param Table $table The Table model class to add PK to.
  */
 protected function addPrimaryKey(Table $table)
 {
     $stmt = $this->dbh->query("SELECT COLS.COLUMN_NAME FROM USER_CONSTRAINTS CONS, USER_CONS_COLUMNS COLS WHERE CONS.CONSTRAINT_NAME = COLS.CONSTRAINT_NAME AND CONS.TABLE_NAME = '" . $table->getName() . "' AND CONS.CONSTRAINT_TYPE = 'P'");
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         // This fixes a strange behavior by PDO. Sometimes the
         // row values are inside an index 0 of an array
         if (isset($row[0])) {
             $row = $row[0];
         }
         $table->getColumn($row['COLUMN_NAME'])->setPrimaryKey(true);
     }
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:17,代码来源:OracleSchemaParser.php

示例10: addPrimaryKey

 /**
  * Loads the primary key for this table.
  */
 protected function addPrimaryKey(Table $table, $oid)
 {
     $stmt = $this->dbh->prepare("SELECT\n            DISTINCT ON(cls.relname)\n            cls.relname as idxname,\n            indkey,\n            indisunique\n            FROM pg_index idx\n            JOIN pg_class cls ON cls.oid=indexrelid\n            WHERE indrelid = ? AND indisprimary\n            ORDER BY cls.relname");
     $stmt->bindValue(1, $oid);
     $stmt->execute();
     // Loop through the returned results, grouping the same key_name together
     // adding each column for that key.
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $arrColumns = explode(' ', $row['indkey']);
         foreach ($arrColumns as $intColNum) {
             $stmt2 = $this->dbh->prepare("SELECT a.attname\n                    FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid\n                    WHERE c.oid = ? AND a.attnum = ? AND NOT a.attisdropped\n                    ORDER BY a.attnum");
             $stmt2->bindValue(1, $oid);
             $stmt2->bindValue(2, $intColNum);
             $stmt2->execute();
             $row2 = $stmt2->fetch(\PDO::FETCH_ASSOC);
             if (!$table->getColumn($row2['attname'])) {
                 continue;
             }
             $table->getColumn($row2['attname'])->setPrimaryKey(true);
         }
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:25,代码来源:PgsqlSchemaParser.php

示例11: addForeignKey

 /**
  * Adds a relation from logTable to origin table.
  *
  * @param Table $logTable
  */
 protected function addForeignKey(Table $logTable)
 {
     $table = $this->getTable();
     if ($table->getForeignKeysReferencingTable($table->getName())) {
         //if already a foreignKey exist to origin table then don't add a second.
         return;
     }
     // create the foreign key
     $fk = new ForeignKey();
     $fk->setForeignTableCommonName($table->getCommonName());
     $fk->setForeignSchemaName($table->getSchema());
     $fk->setPhpName('Origin');
     $fk->setOnDelete('CASCADE');
     $fk->setOnUpdate('CASCADE');
     foreach ($table->getPrimaryKey() as $column) {
         $fk->addReference($logTable->getColumn($column->getName()), $column);
     }
     $logTable->addForeignKey($fk);
 }
开发者ID:marcj,项目名称:change-logger-behavior,代码行数:24,代码来源:ChangeLoggerBehavior.php

示例12: addPrimaryKey

 /**
  * Loads the primary key for this table.
  */
 protected function addPrimaryKey(Table $table)
 {
     $stmt = $this->dbh->query("SHOW KEYS FROM `" . $table->getName() . "`");
     // Loop through the returned results, grouping the same key_name together
     // adding each column for that key.
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         // Skip any non-primary keys.
         if ($row['Key_name'] !== 'PRIMARY') {
             continue;
         }
         $name = $row["Column_name"];
         $table->getColumn($name)->setPrimaryKey(true);
     }
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:17,代码来源:MysqlSchemaParser.php

示例13: addPrimaryKey

 /**
  * Loads the primary key for this table.
  */
 protected function addPrimaryKey(Table $table)
 {
     $stmt = $this->dbh->query(sprintf('SHOW KEYS FROM %s', $this->getPlatform()->doQuoting($table->getName())));
     // Loop through the returned results, grouping the same key_name together
     // adding each column for that key.
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         // Skip any non-primary keys.
         if ('PRIMARY' !== $row['Key_name']) {
             continue;
         }
         $name = $row['Column_name'];
         $table->getColumn($name)->setPrimaryKey(true);
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:17,代码来源:MysqlSchemaParser.php

示例14: getColumnForParameter

 /**
  * Returns a column object using a name stored in the behavior parameters.
  * Useful for table behaviors.
  *
  * @param  string $name
  * @return Column
  */
 public function getColumnForParameter($name)
 {
     return $this->table->getColumn($this->getParameter($name));
 }
开发者ID:disider,项目名称:Propel2,代码行数:11,代码来源:Behavior.php

示例15: addPrimaryKey

 /**
  * Loads the primary key for this table.
  */
 protected function addPrimaryKey(Table $table)
 {
     $stmt = $this->dbh->query("SELECT COLUMN_NAME\n            FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS\n            INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ON\n            INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.constraint_name\n            WHERE     (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'PRIMARY KEY') AND\n            (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '" . $table->getName() . "')");
     // Loop through the returned results, grouping the same key_name together
     // adding each column for that key.
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $name = $row[0];
         $table->getColumn($name)->setPrimaryKey(true);
     }
 }
开发者ID:rozwell,项目名称:Propel2,代码行数:13,代码来源:MssqlSchemaParser.php


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