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


PHP Table::getName方法代码示例

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


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

示例1: getDropTableDDL

 public function getDropTableDDL(Table $table)
 {
     $ret = '';
     foreach ($table->getForeignKeys() as $fk) {
         $ret .= "\nIF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='" . $fk->getName() . "')\n    ALTER TABLE " . $this->quoteIdentifier($table->getName()) . " DROP CONSTRAINT " . $this->quoteIdentifier($fk->getName()) . ";\n";
     }
     self::$dropCount++;
     $ret .= "\nIF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = '" . $table->getName() . "')\nBEGIN\n    DECLARE @reftable_" . self::$dropCount . " nvarchar(60), @constraintname_" . self::$dropCount . " nvarchar(60)\n    DECLARE refcursor CURSOR FOR\n    select reftables.name tablename, cons.name constraintname\n        from sysobjects tables,\n            sysobjects reftables,\n            sysobjects cons,\n            sysreferences ref\n        where tables.id = ref.rkeyid\n            and cons.id = ref.constid\n            and reftables.id = ref.fkeyid\n            and tables.name = '" . $table->getName() . "'\n    OPEN refcursor\n    FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . "\n    while @@FETCH_STATUS = 0\n    BEGIN\n        exec ('alter table '+@reftable_" . self::$dropCount . "+' drop constraint '+@constraintname_" . self::$dropCount . ")\n        FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . "\n    END\n    CLOSE refcursor\n    DEALLOCATE refcursor\n    DROP TABLE " . $this->quoteIdentifier($table->getName()) . "\nEND\n";
     return $ret;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:10,代码来源:MssqlPlatform.php

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

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

示例4: objectAttributes

 public function objectAttributes(ObjectBuilder $builder)
 {
     $tableName = $this->table->getName();
     $objectClassName = $builder->getObjectClassName();
     $script = "\n/**\n * Queries to be executed in the save transaction\n * @var        array\n */\nprotected \$nestedSetQueries = array();\n\n/**\n * Internal cache for children nodes\n * @var        null|ObjectCollection\n */\nprotected \$collNestedSetChildren = null;\n\n/**\n * Internal cache for parent node\n * @var        null|{$objectClassName}\n */\nprotected \$aNestedSetParent = null;\n\n/**\n * Left column for the set\n */\nconst LEFT_COL = '" . $tableName . '.' . $this->behavior->getColumnConstant('left_column') . "';\n\n/**\n * Right column for the set\n */\nconst RIGHT_COL = '" . $tableName . '.' . $this->behavior->getColumnConstant('right_column') . "';\n\n/**\n * Level column for the set\n */\nconst LEVEL_COL = '" . $tableName . '.' . $this->behavior->getColumnConstant('level_column') . "';\n";
     if ($this->behavior->useScope()) {
         $script .= "\n/**\n * Scope column for the set\n */\nconst SCOPE_COL = '" . $tableName . '.' . $this->behavior->getColumnConstant('scope_column') . "';\n";
     }
     return $script;
 }
开发者ID:disider,项目名称:Propel2,代码行数:10,代码来源:NestedSetBehaviorObjectBuilderModifier.php

示例5: getAutoIncrementString

 /**
  * Returns the auto-increment string.
  *
  * @return string
  */
 public function getAutoIncrementString()
 {
     if ($this->isAutoIncrement() && IdMethod::NATIVE === $this->parentTable->getIdMethod()) {
         return $this->getPlatform()->getAutoIncrement();
     }
     if ($this->isAutoIncrement()) {
         throw new EngineException(sprintf('You have specified autoIncrement for column "%s", but you have not specified idMethod="native" for table "%s".', $this->name, $this->parentTable->getName()));
     }
     return '';
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:15,代码来源:Column.php

示例6: __toString

 /**
  * Returns the string representation of this object.
  *
  * @return string
  */
 public function __toString()
 {
     $ret = '';
     $ret .= sprintf("  %s:\n", $this->fromTable->getName());
     if ($addedColumns = $this->getAddedColumns()) {
         $ret .= "    addedColumns:\n";
         foreach ($addedColumns as $colname => $column) {
             $ret .= sprintf("      - %s\n", $colname);
         }
     }
     if ($removedColumns = $this->getRemovedColumns()) {
         $ret .= "    removedColumns:\n";
         foreach ($removedColumns as $colname => $column) {
             $ret .= sprintf("      - %s\n", $colname);
         }
     }
     if ($modifiedColumns = $this->getModifiedColumns()) {
         $ret .= "    modifiedColumns:\n";
         foreach ($modifiedColumns as $colDiff) {
             $ret .= $colDiff->__toString();
         }
     }
     if ($renamedColumns = $this->getRenamedColumns()) {
         $ret .= "    renamedColumns:\n";
         foreach ($renamedColumns as $columnRenaming) {
             list($fromColumn, $toColumn) = $columnRenaming;
             $ret .= sprintf("      %s: %s\n", $fromColumn->getName(), $toColumn->getName());
         }
     }
     if ($addedIndices = $this->getAddedIndices()) {
         $ret .= "    addedIndices:\n";
         foreach ($addedIndices as $indexName => $index) {
             $ret .= sprintf("      - %s\n", $indexName);
         }
     }
     if ($removedIndices = $this->getRemovedIndices()) {
         $ret .= "    removedIndices:\n";
         foreach ($removedIndices as $indexName => $index) {
             $ret .= sprintf("      - %s\n", $indexName);
         }
     }
     if ($modifiedIndices = $this->getModifiedIndices()) {
         $ret .= "    modifiedIndices:\n";
         foreach ($modifiedIndices as $indexName => $indexDiff) {
             $ret .= sprintf("      - %s\n", $indexName);
         }
     }
     if ($addedFks = $this->getAddedFks()) {
         $ret .= "    addedFks:\n";
         foreach ($addedFks as $fkName => $fk) {
             $ret .= sprintf("      - %s\n", $fkName);
         }
     }
     if ($removedFks = $this->getRemovedFks()) {
         $ret .= "    removedFks:\n";
         foreach ($removedFks as $fkName => $fk) {
             $ret .= sprintf("      - %s\n", $fkName);
         }
     }
     if ($modifiedFks = $this->getModifiedFks()) {
         $ret .= "    modifiedFks:\n";
         foreach ($modifiedFks as $fkName => $fkFromTo) {
             $ret .= sprintf("      %s:\n", $fkName);
             list($fromFk, $toFk) = $fkFromTo;
             $fromLocalColumns = json_encode($fromFk->getLocalColumns());
             $toLocalColumns = json_encode($toFk->getLocalColumns());
             if ($fromLocalColumns != $toLocalColumns) {
                 $ret .= sprintf("          localColumns: from %s to %s\n", $fromLocalColumns, $toLocalColumns);
             }
             $fromForeignColumns = json_encode($fromFk->getForeignColumns());
             $toForeignColumns = json_encode($toFk->getForeignColumns());
             if ($fromForeignColumns != $toForeignColumns) {
                 $ret .= sprintf("          foreignColumns: from %s to %s\n", $fromForeignColumns, $toForeignColumns);
             }
             if ($fromFk->normalizeFKey($fromFk->getOnUpdate()) != $toFk->normalizeFKey($toFk->getOnUpdate())) {
                 $ret .= sprintf("          onUpdate: from %s to %s\n", $fromFk->getOnUpdate(), $toFk->getOnUpdate());
             }
             if ($fromFk->normalizeFKey($fromFk->getOnDelete()) != $toFk->normalizeFKey($toFk->getOnDelete())) {
                 $ret .= sprintf("          onDelete: from %s to %s\n", $fromFk->getOnDelete(), $toFk->getOnDelete());
             }
         }
     }
     return $ret;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:89,代码来源:TableDiff.php

示例7: getPrimaryKeyName

 public function getPrimaryKeyName(Table $table)
 {
     $tableName = $table->getName();
     return $tableName . '_pkey';
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:5,代码来源:PgsqlPlatform.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: addColumns

 /**
  * Adds Columns to the specified table.
  *
  * @param Table $table The Table model class to add columns to.
  * @param int   $oid   The table OID
  */
 protected function addColumns(Table $table, $oid)
 {
     // Get the columns, types, etc.
     // Based on code from pgAdmin3 (http://www.pgadmin.org/)
     $searchPath = '?';
     $params = [$table->getDatabase()->getSchema()];
     if ($schema = $table->getSchema()) {
         $searchPath = '?';
         $params = [$schema];
     } else {
         if (!$table->getDatabase()->getSchema()) {
             $stmt = $this->dbh->query('SHOW search_path');
             $searchPathString = $stmt->fetchColumn();
             $params = [];
             $searchPath = explode(',', $searchPathString);
             foreach ($searchPath as &$path) {
                 $params[] = $path;
                 $path = '?';
             }
             $searchPath = implode(', ', $searchPath);
         }
     }
     $stmt = $this->dbh->prepare("\n        SELECT\n            column_name,\n            data_type,\n            column_default,\n            is_nullable,\n            numeric_precision,\n            numeric_scale,\n            character_maximum_length\n        FROM information_schema.columns\n        WHERE\n            table_schema IN ({$searchPath}) AND table_name = ?\n        ");
     $params[] = $table->getCommonName();
     $stmt->execute($params);
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $size = $row['character_maximum_length'];
         if (!$size) {
             $size = $row['numeric_precision'];
         }
         $scale = $row['numeric_scale'];
         $name = $row['column_name'];
         $type = $row['data_type'];
         $default = $row['column_default'];
         $isNullable = true === $row['is_nullable'] || 'YES' === strtoupper($row['is_nullable']);
         // Check to ensure that this column isn't an array data type
         if ('ARRAY' === $type) {
             $this->warn(sprintf('Array datatypes are not currently supported [%s.%s]', $table->getName(), $name));
             continue;
         }
         $autoincrement = null;
         // if column has a default
         if (strlen(trim($default)) > 0) {
             if (!preg_match('/^nextval\\(/', $default)) {
                 $strDefault = preg_replace('/::[\\W\\D]*/', '', $default);
             } else {
                 $autoincrement = true;
                 $default = null;
             }
         } else {
             $default = null;
         }
         $propelType = $this->getMappedPropelType($type);
         if (!$propelType) {
             $propelType = Column::DEFAULT_TYPE;
             $this->warn('Column [' . $table->getName() . '.' . $name . '] has a column type (' . $type . ') that Propel does not support.');
         }
         if (isset(static::$defaultTypeSizes[$type]) && $size == static::$defaultTypeSizes[$type]) {
             $size = null;
         }
         if ('SERIAL' === substr(strtoupper($type), 0, 6)) {
             $autoincrement = true;
             $default = null;
         }
         $column = new Column($name);
         $column->setTable($table);
         $column->setDomainForType($propelType);
         $column->getDomain()->replaceSize($size);
         if ($scale) {
             $column->getDomain()->replaceScale($scale);
         }
         if (null !== $default) {
             if ("'" !== substr($default, 0, 1) && strpos($default, '(')) {
                 $defaultType = ColumnDefaultValue::TYPE_EXPR;
             } else {
                 $defaultType = ColumnDefaultValue::TYPE_VALUE;
                 $default = str_replace("'", '', $strDefault);
             }
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, $defaultType));
         }
         $column->setAutoIncrement($autoincrement);
         $column->setNotNull(!$isNullable);
         $table->addColumn($column);
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:91,代码来源:PgsqlSchemaParser.php

示例10: getTriggerName

 /**
  * Returns the trigger name.
  *
  * @param Table $table
  *
  * @return string
  */
 protected function getTriggerName(Table $table)
 {
     $tableName = $table->getName();
     /** @var CompositeNumberRangeBehavior $behavior */
     $behavior = $table->getBehavior(self::BEHAVIOR_NAME);
     $foreignTableName = $behavior->getForeignTable();
     return str_replace(' ', '', ucwords(str_replace('_', ' ', 'set' . ucfirst($foreignTableName) . ucfirst($tableName) . 'Id')));
 }
开发者ID:apinnecke,项目名称:composite-number-range-behavior,代码行数:15,代码来源:MysqlPlatform.php

示例11: testGetNameWithPlatform

 /**
  * @dataProvider provideSchemaNames
  *
  */
 public function testGetNameWithPlatform($supportsSchemas, $schemaName, $expectedName)
 {
     $database = $this->getDatabaseMock($schemaName, array('platform' => $this->getPlatformMock($supportsSchemas)));
     $database->expects($supportsSchemas ? $this->once() : $this->never())->method('getSchemaDelimiter')->will($this->returnValue('.'));
     $table = new Table('books');
     $table->setSchema($schemaName);
     $table->setDatabase($database);
     $this->assertSame($expectedName, $table->getName());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:TableTest.php

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

示例13: getSequenceName

 /**
  * Override to provide sequence names that conform to postgres' standard when
  * no id-method-parameter specified.
  *
  * @param Table $table
  *
  * @return string
  */
 public function getSequenceName(Table $table)
 {
     $result = null;
     if ($table->getIdMethod() == IdMethod::NATIVE) {
         $idMethodParams = $table->getIdMethodParameters();
         if (empty($idMethodParams)) {
             $result = null;
             // We're going to ignore a check for max length (mainly
             // because I'm not sure how Postgres would handle this w/ SERIAL anyway)
             foreach ($table->getColumns() as $col) {
                 if ($col->isAutoIncrement()) {
                     $result = $table->getName() . '_' . $col->getName() . '_seq';
                     break;
                     // there's only one auto-increment column allowed
                 }
             }
         } else {
             $result = $idMethodParams[0]->getValue();
         }
     }
     return $result;
 }
开发者ID:disider,项目名称:Propel2,代码行数:30,代码来源:PgsqlPlatform.php

示例14: addTableVendorInfo

 /**
  * Adds vendor-specific info for table.
  *
  * @param      Table $table
  */
 protected function addTableVendorInfo(Table $table)
 {
     $stmt = $this->dbh->query("SHOW TABLE STATUS LIKE '" . $table->getName() . "'");
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $vi = $this->getNewVendorInfoObject($row);
     $table->addVendorInfo($vi);
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:12,代码来源:MysqlSchemaParser.php

示例15: addTableVendorInfo

 /**
  * Adds vendor-specific info for table.
  *
  * @param Table $table
  */
 protected function addTableVendorInfo(Table $table)
 {
     $stmt = $this->dbh->query("SHOW TABLE STATUS LIKE '" . $table->getName() . "'");
     $row = $stmt->fetch(\PDO::FETCH_ASSOC);
     if (!$this->addVendorInfo) {
         // since we depend on `Engine` in the MysqlPlatform, we always have to extract this vendor information
         $row = array('Engine' => $row['Engine']);
     }
     $vi = $this->getNewVendorInfoObject($row);
     $table->addVendorInfo($vi);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:16,代码来源:MysqlSchemaParser.php


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