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


PHP Model\Table类代码示例

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


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

 public function testTable()
 {
     $b = new Behavior();
     $this->assertNull($b->getTable(), 'Behavior Table is null by default');
     $t = new Table();
     $t->setCommonName('fooTable');
     $b->setTable($t);
     $this->assertEquals($b->getTable(), $t, 'setTable() sets the name, and getTable() gets it');
 }
开发者ID:robin850,项目名称:Propel2,代码行数:9,代码来源:BehaviorTest.php

示例3: 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

示例4: testTableNamespaceAndDbNamespace

 public function testTableNamespaceAndDbNamespace()
 {
     $d = new Database('fooDb');
     $d->setNamespace('Baz');
     $t = new Table('fooTable');
     $t->setNamespace('Foo\\Bar');
     $d->addTable($t);
     $builder = new TestableOMBuilder2($t);
     $this->assertEquals('Baz\\Foo\\Bar', $builder->getNamespace(), 'Builder namespace is composed from the database and table namespaces when both are set');
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:10,代码来源:AbstractOMBuilderNamespaceTest.php

示例5: _before

 /**
  * @return void
  */
 protected function _before()
 {
     $config = new QuickGeneratorConfig();
     $table = new Table('Foo');
     $column = new Column('testColumn', PropelTypes::INTEGER);
     $table->addColumn($column);
     $table->setNamespace('Unit\\Spryker\\Zed\\Propel\\Business\\Builder\\QueryBuilder');
     $table->setDatabase(new Database('TestDB', new DefaultPlatform()));
     foreach ($this->getFilesToGenerate() as $fileName => $builderClass) {
         $builder = new $builderClass($table);
         $builder->setGeneratorConfig($config);
         $this->writePropelFile($builder, $fileName);
     }
 }
开发者ID:spryker,项目名称:Propel,代码行数:17,代码来源:QueryBuilderTest.php

示例6: hasPlatform

 /**
  * Returns whether or not this column has a platform adapter.
  *
  * @return boolean
  */
 public function hasPlatform()
 {
     if (null === $this->parentTable) {
         return false;
     }
     return $this->parentTable->getPlatform() ? true : false;
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:12,代码来源:Column.php

示例7: buildFormFields

 /**
  * Build the fields in the FormType.
  *
  * @param Table $table Table from which the fields will be extracted.
  *
  * @return string The FormType code.
  */
 protected function buildFormFields(Table $table)
 {
     $buildCode = '';
     foreach ($table->getColumns() as $column) {
         if ($column->isPrimaryKey()) {
             continue;
         }
         $name = $column->getPhpName();
         // Use foreignKey table name, so the TypeGuesser gets it right
         if ($column->isForeignKey()) {
             /** @var ForeignKey $foreignKey */
             $foreignKey = current($column->getForeignKeys());
             $name = $foreignKey->getForeignTable()->getPhpName();
         }
         $buildCode .= sprintf("\n        \$builder->add('%s');", lcfirst($name));
     }
     return $buildCode;
 }
开发者ID:naldz,项目名称:cyberden,代码行数:25,代码来源:FormBuilder.php

示例8: getOtherFks

 /**
  * Returns the list of other foreign keys starting on the same table.
  * Used in many-to-many relationships.
  *
  * @return ForeignKey[]
  */
 public function getOtherFks()
 {
     $fks = [];
     foreach ($this->parentTable->getForeignKeys() as $fk) {
         if ($fk !== $this) {
             $fks[] = $fk;
         }
     }
     return $fks;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:16,代码来源:ForeignKey.php

示例9: getPlatform

 /**
  * Convenience method to returns the Platform class for this table (database).
  * @return PlatformInterface
  */
 public function getPlatform()
 {
     if (null === $this->platform) {
         // try to load the platform from the table
         $table = $this->getTable();
         if ($table && ($database = $table->getDatabase())) {
             $this->setPlatform($database->getPlatform());
         }
     }
     if (!$this->table->isIdentifierQuotingEnabled()) {
         $this->platform->setIdentifierQuoting(false);
     }
     return $this->platform;
 }
开发者ID:disider,项目名称:Propel2,代码行数:18,代码来源:DataModelBuilder.php

示例10: endElement

 public function endElement($parser, $name)
 {
     if ('index' === $name) {
         $this->currTable->addIndex($this->currIndex);
     } else {
         if ('unique' === $name) {
             $this->currTable->addUnique($this->currUnique);
         }
     }
     if (self::DEBUG) {
         print 'endElement(' . $name . ") called\n";
     }
     $this->popCurrentSchemaTag();
 }
开发者ID:malukenho,项目名称:Propel2,代码行数:14,代码来源:SchemaReader.php

示例11: 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

示例12: 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

示例13: addToArrayKeyLookUp

 /**
  * Adds the switch-statement for looking up the array-key name for toArray
  * @see toArray
  */
 protected function addToArrayKeyLookUp($phpName, Table $table, $plural)
 {
     if ($phpName == "") {
         $phpName = $table->getPhpName();
     }
     $camelCaseName = $table->getCamelCaseName();
     $fieldName = $table->getName();
     if ($plural) {
         $phpName = $this->getPluralizer()->getPluralForm($phpName);
         $camelCaseName = $this->getPluralizer()->getPluralForm($camelCaseName);
         $fieldName = $this->getPluralizer()->getPluralForm($fieldName);
     }
     return "\n                switch (\$keyType) {\n                    case TableMap::TYPE_CAMELNAME:\n                        \$key = '" . $camelCaseName . "';\n                        break;\n                    case TableMap::TYPE_FIELDNAME:\n                        \$key = '" . $fieldName . "';\n                        break;\n                    default:\n                        \$key = '" . $phpName . "';\n                }\n        ";
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:18,代码来源:ObjectBuilder.php

示例14: testGetPrimaryKeyDDLCompositeKey

 public function testGetPrimaryKeyDDLCompositeKey()
 {
     $table = new Table('foo');
     $column1 = new Column('bar1');
     $column1->setPrimaryKey(true);
     $table->addColumn($column1);
     $column2 = new Column('bar2');
     $column2->setPrimaryKey(true);
     $table->addColumn($column2);
     $expected = 'PRIMARY KEY ([bar1],[bar2])';
     $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table));
 }
开发者ID:disider,项目名称:Propel2,代码行数:12,代码来源:SqlitePlatformTest.php

示例15: 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


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