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


PHP Table::hasPrimaryKey方法代码示例

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


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

示例1: getPrimaryKeyDDL

 public function getPrimaryKeyDDL(Table $table)
 {
     if ($table->hasPrimaryKey()) {
         $pattern = 'CONSTRAINT %s PRIMARY KEY (%s)';
         return sprintf($pattern, $this->quoteIdentifier($this->getPrimaryKeyName($table)), $this->getColumnListDDL($table->getPrimaryKey()));
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:7,代码来源:MssqlPlatform.php

示例2: getPrimaryKeyDDL

 /**
  * Returns the SQL for the primary key of a Table object.
  *
  * @return string
  */
 public function getPrimaryKeyDDL(Table $table)
 {
     if ($table->hasPrimaryKey() && 1 < count($table->getPrimaryKey())) {
         if ($table->hasAutoIncrementPrimaryKey()) {
             return 'UNIQUE (' . $this->getColumnListDDL($table->getPrimaryKey()) . ')';
         }
         return 'PRIMARY KEY (' . $this->getColumnListDDL($table->getPrimaryKey()) . ')';
     }
 }
开发者ID:robin850,项目名称:Propel2,代码行数:14,代码来源:SqlitePlatform.php

示例3: validateTableColumns

 protected function validateTableColumns(Table $table)
 {
     if (!$table->hasPrimaryKey() && !$table->isSkipSql()) {
         $this->errors[] = sprintf('Table "%s" does not have a primary key defined. Propel requires all tables to have a primary key.', $table->getName());
     }
     $phpNames = [];
     foreach ($table->getColumns() as $column) {
         if (in_array($column->getPhpName(), $phpNames)) {
             $this->errors[] = sprintf('Column "%s" declares a phpName already used in table "%s"', $column->getName(), $table->getName());
         }
         $phpNames[] = $column->getPhpName();
     }
 }
开发者ID:disider,项目名称:Propel2,代码行数:13,代码来源:SchemaValidator.php

示例4: getAddTableDDL

 public function getAddTableDDL(Table $table)
 {
     $tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : '';
     $lines = array();
     foreach ($table->getColumns() as $column) {
         $lines[] = $this->getColumnDDL($column);
     }
     if ($table->hasPrimaryKey() && count($table->getPrimaryKey()) > 1) {
         $lines[] = $this->getPrimaryKeyDDL($table);
     }
     foreach ($table->getUnices() as $unique) {
         $lines[] = $this->getUniqueDDL($unique);
     }
     $sep = ",\n    ";
     $pattern = "\n%sCREATE TABLE %s\n(\n    %s\n);\n";
     return sprintf($pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines));
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:17,代码来源:SqlitePlatform.php

示例5: getDropPrimaryKeyDDL

 /**
  * Builds the DDL SQL to drop the primary key of a table.
  *
  * @param  Table  $table
  * @return string
  */
 public function getDropPrimaryKeyDDL(Table $table)
 {
     if (!$table->hasPrimaryKey()) {
         return '';
     }
     $pattern = "\nALTER TABLE %s DROP PRIMARY KEY;\n";
     return sprintf($pattern, $this->quoteIdentifier($table->getName()));
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:14,代码来源:MysqlPlatform.php

示例6: getAddTableDDL

 public function getAddTableDDL(Table $table)
 {
     $lines = array();
     foreach ($table->getColumns() as $column) {
         $lines[] = $this->getColumnDDL($column);
     }
     if ($table->hasPrimaryKey()) {
         $lines[] = $this->getPrimaryKeyDDL($table);
     }
     foreach ($table->getUnices() as $unique) {
         $lines[] = $this->getUniqueDDL($unique);
     }
     foreach ($table->getIndices() as $index) {
         $lines[] = $this->getIndexDDL($index);
     }
     foreach ($table->getForeignKeys() as $foreignKey) {
         if ($foreignKey->isSkipSql()) {
             continue;
         }
         $lines[] = str_replace("\n    ", "\n        ", $this->getForeignKeyDDL($foreignKey));
     }
     $vendorSpecific = $table->getVendorInfoForType('mysql');
     if ($vendorSpecific->hasParameter('Type')) {
         $mysqlTableType = $vendorSpecific->getParameter('Type');
     } elseif ($vendorSpecific->hasParameter('Engine')) {
         $mysqlTableType = $vendorSpecific->getParameter('Engine');
     } else {
         $mysqlTableType = $this->getDefaultTableEngine();
     }
     $tableOptions = $this->getTableOptions($table);
     if ($table->getDescription()) {
         $tableOptions[] = 'COMMENT=' . $this->quote($table->getDescription());
     }
     $tableOptions = $tableOptions ? ' ' . implode(' ', $tableOptions) : '';
     $sep = ",\n    ";
     $pattern = "\nCREATE TABLE %s\n(\n    %s\n) %s=%s%s;\n";
     return sprintf($pattern, $this->quoteIdentifier($table->getName()), implode($sep, $lines), $this->getTableEngineKeyword(), $mysqlTableType, $tableOptions);
 }
开发者ID:norfil,项目名称:Propel2,代码行数:38,代码来源:MysqlPlatform.php

示例7: testGetAutoIncrementPrimaryKey

 public function testGetAutoIncrementPrimaryKey()
 {
     $column1 = $this->getColumnMock('id', array('primary' => true, 'auto_increment' => true));
     $column2 = $this->getColumnMock('title');
     $column3 = $this->getColumnMock('isbn');
     $table = new Table();
     $table->setIdMethod('native');
     $table->addColumn($column1);
     $table->addColumn($column2);
     $table->addColumn($column3);
     $this->assertCount(1, $table->getPrimaryKey());
     $this->assertTrue($table->hasPrimaryKey());
     $this->assertTrue($table->hasAutoIncrementPrimaryKey());
     $this->assertSame($column1, $table->getAutoIncrementPrimaryKey());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:15,代码来源:TableTest.php

示例8: getAddPrimaryKeyDDL

 /**
  * Returns the DDL SQL to add the primary key of a table.
  *
  * @param  Table  $table From Table
  * @return string
  */
 public function getAddPrimaryKeyDDL(Table $table)
 {
     if (!$table->hasPrimaryKey()) {
         return '';
     }
     $pattern = "\nALTER TABLE %s ADD %s;\n";
     return sprintf($pattern, $this->quoteIdentifier($table->getName()), $this->getPrimaryKeyDDL($table));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:14,代码来源:DefaultPlatform.php

示例9: getPrimaryKeyDDL

 /**
  * Returns the SQL for the primary key of a Table object
  * @return     string
  */
 public function getPrimaryKeyDDL(Table $table)
 {
     if ($table->hasPrimaryKey()) {
         return 'PRIMARY KEY (' . $this->getColumnListDDL($table->getPrimaryKey()) . ')';
     }
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:10,代码来源:DefaultPlatform.php


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