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


PHP Table::getColumns方法代码示例

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


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

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

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

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

示例4: addUpdateLoadedNodes

 protected function addUpdateLoadedNodes(&$script)
 {
     $queryClassName = $this->queryClassName;
     $objectClassName = $this->objectClassName;
     $tableMapClassName = $this->tableMapClassName;
     $script .= "\n/**\n * Reload all already loaded nodes to sync them with updated db\n *\n * @param      {$objectClassName} \$prune        Object to prune from the update\n * @param      ConnectionInterface \$con        Connection to use.\n */\nstatic public function updateLoadedNodes(\$prune = null, ConnectionInterface \$con = null)\n{\n    if (Propel::isInstancePoolingEnabled()) {\n        \$keys = array();\n        /** @var \$obj {$objectClassName} */\n        foreach ({$tableMapClassName}::\$instances as \$obj) {\n            if (!\$prune || !\$prune->equals(\$obj)) {\n                \$keys[] = \$obj->getPrimaryKey();\n            }\n        }\n\n        if (!empty(\$keys)) {\n            // We don't need to alter the object instance pool; we're just modifying these ones\n            // already in the pool.\n            \$criteria = new Criteria({$tableMapClassName}::DATABASE_NAME);";
     if (1 === count($this->table->getPrimaryKey())) {
         $pkey = $this->table->getPrimaryKey();
         $col = array_shift($pkey);
         $script .= "\n            \$criteria->add(" . $this->builder->getColumnConstant($col) . ", \$keys, Criteria::IN);";
     } else {
         $fields = array();
         foreach ($this->table->getPrimaryKey() as $k => $col) {
             $fields[] = $this->builder->getColumnConstant($col);
         }
         $script .= "\n\n            // Loop on each instances in pool\n            foreach (\$keys as \$values) {\n              // Create initial Criterion\n                \$cton = \$criteria->getNewCriterion(" . $fields[0] . ", \$values[0]);";
         unset($fields[0]);
         foreach ($fields as $k => $col) {
             $script .= "\n\n                // Create next criterion\n                \$nextcton = \$criteria->getNewCriterion(" . $col . ", \$values[{$k}]);\n                // And merge it with the first\n                \$cton->addAnd(\$nextcton);";
         }
         $script .= "\n\n                // Add final Criterion to Criteria\n                \$criteria->addOr(\$cton);\n            }";
     }
     $script .= "\n            \$dataFetcher = {$queryClassName}::create(null, \$criteria)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con);\n            while (\$row = \$dataFetcher->fetch()) {\n                \$key = {$tableMapClassName}::getPrimaryKeyHashFromRow(\$row, 0);\n                /** @var \$object {$objectClassName} */\n                if (null !== (\$object = {$tableMapClassName}::getInstanceFromPool(\$key))) {";
     $n = 0;
     foreach ($this->table->getColumns() as $col) {
         if ($col->isLazyLoad()) {
             continue;
         }
         if ($col->getPhpName() == $this->getColumnPhpName('left_column')) {
             $script .= "\n                    \$object->setLeftValue(\$row[{$n}]);";
         } elseif ($col->getPhpName() == $this->getColumnPhpName('right_column')) {
             $script .= "\n                    \$object->setRightValue(\$row[{$n}]);";
         } elseif ($this->getParameter('use_scope') == 'true' && $col->getPhpName() == $this->getColumnPhpName('scope_column')) {
             $script .= "\n                    \$object->setScopeValue(\$row[{$n}]);";
         } elseif ($col->getPhpName() == $this->getColumnPhpName('level_column')) {
             $script .= "\n                    \$object->setLevel(\$row[{$n}]);\n                    \$object->clearNestedSetChildren();";
         }
         $n++;
     }
     $script .= "\n                }\n            }\n            \$dataFetcher->close();\n        }\n    }\n}\n";
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:41,代码来源:NestedSetBehaviorQueryBuilderModifier.php

示例5: 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);
     }
     if ($this->supportsForeignKeys($table)) {
         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:kalaspuffar,项目名称:php-orm-benchmark,代码行数:40,代码来源:MysqlPlatform.php

示例6: getAddTableDDL

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

示例7: testRemoveColumn

 public function testRemoveColumn()
 {
     $column1 = $this->getColumnMock('id');
     $column2 = $this->getColumnMock('title');
     $column3 = $this->getColumnMock('isbn');
     $table = new Table('books');
     $table->addColumn($column1);
     $table->addColumn($column2);
     $table->addColumn($column3);
     $table->removeColumn($column2);
     $this->assertCount(2, $table->getColumns());
     $this->assertTrue($table->hasColumn('id'));
     $this->assertTrue($table->hasColumn('isbn'));
     $this->assertFalse($table->hasColumn('title'));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:15,代码来源:TableTest.php

示例8: getAddColumnsComments

 protected function getAddColumnsComments(Table $table)
 {
     $ret = '';
     foreach ($table->getColumns() as $column) {
         $ret .= $this->getAddColumnComment($column);
     }
     return $ret;
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:8,代码来源:PgsqlPlatform.php

示例9: normalizeTable

 /**
  * Normalizes a table for the current platform. Very important for the TableComparator to not
  * generate useless diffs.
  * Useful for checking needed definitions/structures. E.g. Unique Indexes for ForeignKey columns,
  * which the most Platforms requires but which is not always explicitly defined in the table model.
  *
  * @param Table $table The table object which gets modified.
  */
 public function normalizeTable(Table $table)
 {
     if ($table->hasForeignKeys()) {
         foreach ($table->getForeignKeys() as $fk) {
             if ($fk->getForeignTable() && !$fk->getForeignTable()->isUnique($fk->getForeignColumnObjects())) {
                 $unique = new Unique();
                 $unique->setColumns($fk->getForeignColumnObjects());
                 $fk->getForeignTable()->addUnique($unique);
             }
         }
     }
     if (!$this->supportsIndexSize() && $table->getIndices()) {
         // when the plafform does not support index sizes we reset it
         foreach ($table->getIndices() as $index) {
             $index->resetColumnsSize();
         }
     }
     foreach ($table->getColumns() as $column) {
         if ($column->getSize() && ($defaultSize = $this->getDefaultTypeSize($column->getType()))) {
             if (null === $column->getScale() && intval($column->getSize()) === $defaultSize) {
                 $column->setSize(null);
             }
         }
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:33,代码来源:DefaultPlatform.php

示例10: testRemoveColumnFixesPositions

 public function testRemoveColumnFixesPositions()
 {
     $table = new Table();
     $col1 = new Column('Foo1');
     $table->addColumn($col1);
     $col2 = new Column('Foo2');
     $table->addColumn($col2);
     $col3 = new Column('Foo3');
     $table->addColumn($col3);
     $this->assertEquals(1, $col1->getPosition());
     $this->assertEquals(2, $col2->getPosition());
     $this->assertEquals(3, $col3->getPosition());
     $this->assertEquals(array(0, 1, 2), array_keys($table->getColumns()));
     $table->removeColumn($col2);
     $this->assertEquals(1, $col1->getPosition());
     $this->assertEquals(2, $col3->getPosition());
     $this->assertEquals(array(0, 1), array_keys($table->getColumns()));
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:18,代码来源:TableTest.php

示例11: appendTableNode

 /**
  * Appends the generated <table> XML node to its parent node.
  *
  * @param Table    $table      The Table model instance
  * @param \DOMNode $parentNode The parent DOMNode object
  */
 private function appendTableNode(Table $table, \DOMNode $parentNode)
 {
     $tableNode = $parentNode->appendChild($this->document->createElement('table'));
     $tableNode->setAttribute('name', $table->getCommonName());
     $database = $table->getDatabase();
     $schema = $table->getSchema();
     if ($schema && $schema !== $database->getSchema()) {
         $tableNode->setAttribute('schema', $schema);
     }
     if (IdMethod::NO_ID_METHOD !== ($idMethod = $table->getIdMethod())) {
         $tableNode->setAttribute('idMethod', $idMethod);
     }
     if ($phpName = $table->getPhpName()) {
         $tableNode->setAttribute('phpName', $phpName);
     }
     $package = $table->getPackage();
     if ($package && !$table->isPackageOverriden()) {
         $tableNode->setAttribute('package', $package);
     }
     if ($namespace = $table->getNamespace()) {
         $tableNode->setAttribute('namespace', $namespace);
     }
     if ($table->isSkipSql()) {
         $tableNode->setAttribute('skipSql', 'true');
     }
     if ($table->isAbstract()) {
         $tableNode->setAttribute('abstract', 'true');
     }
     if ($interface = $table->getInterface()) {
         $tableNode->setAttribute('interface', $interface);
     }
     if ($table->isCrossRef()) {
         $tableNode->setAttribute('isCrossRef', 'true');
     }
     $phpNamingMethod = $table->getPhpNamingMethod();
     if ($phpNamingMethod && $phpNamingMethod !== $database->getDefaultPhpNamingMethod()) {
         $tableNode->setAttribute('phpNamingMethod', $phpNamingMethod);
     }
     if ($baseClass = $table->getBaseClass()) {
         $tableNode->setAttribute('baseClass', $baseClass);
     }
     if ($baseQueryClass = $table->getBaseQueryClass()) {
         $tableNode->setAttribute('baseQueryClass', $baseQueryClass);
     }
     if ($table->isReadOnly()) {
         $tableNode->setAttribute('readOnly', 'true');
     }
     if ($table->isReloadOnInsert()) {
         $tableNode->setAttribute('reloadOnInsert', 'true');
     }
     if ($table->isReloadOnUpdate()) {
         $tableNode->setAttribute('reloadOnUpdate', 'true');
     }
     if (null !== ($referenceOnly = $table->isForReferenceOnly())) {
         $tableNode->setAttribute('forReferenceOnly', $referenceOnly ? 'true' : 'false');
     }
     if ($alias = $table->getAlias()) {
         $tableNode->setAttribute('alias', $alias);
     }
     if ($description = $table->getDescription()) {
         $tableNode->setAttribute('description', $description);
     }
     $defaultStringFormat = $table->getDefaultStringFormat();
     if (Table::DEFAULT_STRING_FORMAT !== $defaultStringFormat) {
         $tableNode->setAttribute('defaultStringFormat', $defaultStringFormat);
     }
     $defaultAccessorVisibility = $table->getDefaultAccessorVisibility();
     if ($defaultAccessorVisibility !== Table::VISIBILITY_PUBLIC) {
         $tableNode->setAttribute('defaultAccessorVisibility', $defaultAccessorVisibility);
     }
     $defaultMutatorVisibility = $table->getDefaultMutatorVisibility();
     if ($defaultMutatorVisibility !== Table::VISIBILITY_PUBLIC) {
         $tableNode->setAttribute('defaultMutatorVisibility', $defaultMutatorVisibility);
     }
     foreach ($table->getColumns() as $column) {
         $this->appendColumnNode($column, $tableNode);
     }
     foreach ($table->getForeignKeys() as $foreignKey) {
         $this->appendForeignKeyNode($foreignKey, $tableNode);
     }
     foreach ($table->getIdMethodParameters() as $parameter) {
         $this->appendIdMethodParameterNode($parameter, $tableNode);
     }
     foreach ($table->getIndices() as $index) {
         $this->appendIndexNode($index, $tableNode);
     }
     foreach ($table->getUnices() as $index) {
         $this->appendUniqueIndexNode($index, $tableNode);
     }
     foreach ($table->getVendorInformation() as $vendorInformation) {
         $this->appendVendorInformationNode($vendorInformation, $tableNode);
     }
     foreach ($table->getBehaviors() as $behavior) {
         $this->appendBehaviorNode($behavior, $tableNode);
//.........这里部分代码省略.........
开发者ID:SwissalpS,项目名称:Propel2,代码行数:101,代码来源:XmlDumper.php


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