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


PHP Table::getSchema方法代码示例

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


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

示例1: parseTables

 protected function parseTables(Database $database, Table $filterTable = null)
 {
     $sql = "\n        SELECT name\n        FROM sqlite_master\n        WHERE type='table'\n        %filter%\n        UNION ALL\n        SELECT name\n        FROM sqlite_temp_master\n        WHERE type='table'\n        %filter%\n        ORDER BY name;";
     $filter = '';
     if ($filterTable) {
         if ($schema = $filterTable->getSchema()) {
             $filter = sprintf(" AND name LIKE '%s§%%'", $schema);
         }
         $filter .= sprintf(" AND (name = '%s' OR name LIKE '%%§%1\$s')", $filterTable->getCommonName());
     } else {
         if ($schema = $database->getSchema()) {
             $filter = sprintf(" AND name LIKE '%s§%%'", $schema);
         }
     }
     $sql = str_replace('%filter%', $filter, $sql);
     $dataFetcher = $this->dbh->query($sql);
     // First load the tables (important that this happen before filling out details of tables)
     foreach ($dataFetcher as $row) {
         $tableName = $row[0];
         $tableSchema = '';
         if ('sqlite_' == substr($tableName, 0, 7)) {
             continue;
         }
         if (false !== ($pos = strpos($tableName, '§'))) {
             $tableSchema = substr($tableName, 0, $pos);
             $tableName = substr($tableName, $pos + 2);
         }
         $table = new Table($tableName);
         if ($filterTable && $filterTable->getSchema()) {
             $table->setSchema($filterTable->getSchema());
         } else {
             if (!$database->getSchema() && $tableSchema) {
                 //we have no schema to filter, but this belongs to one, so next
                 continue;
             }
         }
         if ($tableName === $this->getMigrationTable()) {
             continue;
         }
         $table->setIdMethod($database->getDefaultIdMethod());
         $database->addTable($table);
     }
 }
开发者ID:KyleGoslan,项目名称:Huge-Propel,代码行数:43,代码来源:SqliteSchemaParser.php

示例2: getSchemaName

 /**
  * Returns the name of the schema the foreign key is in.
  *
  * @return string
  */
 public function getSchemaName()
 {
     return $this->parentTable->getSchema();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:9,代码来源:ForeignKey.php

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

示例4: 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::getSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。