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


PHP Table::options方法代码示例

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


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

示例1: _schemaFromFields

 /**
  * Build the fixtures table schema from the fields property.
  *
  * @return void
  */
 protected function _schemaFromFields()
 {
     $connection = ConnectionManager::get($this->connection());
     $this->_schema = new Table($this->table);
     foreach ($this->fields as $field => $data) {
         if ($field === '_constraints' || $field === '_indexes' || $field === '_options') {
             continue;
         }
         $this->_schema->addColumn($field, $data);
     }
     if (!empty($this->fields['_constraints'])) {
         foreach ($this->fields['_constraints'] as $name => $data) {
             if (!$connection->supportsDynamicConstraints() || $data['type'] !== Table::CONSTRAINT_FOREIGN) {
                 $this->_schema->addConstraint($name, $data);
             } else {
                 $this->_constraints[$name] = $data;
             }
         }
     }
     if (!empty($this->fields['_indexes'])) {
         foreach ($this->fields['_indexes'] as $name => $data) {
             $this->_schema->addIndex($name, $data);
         }
     }
     if (!empty($this->fields['_options'])) {
         $this->_schema->options($this->fields['_options']);
     }
 }
开发者ID:taodf,项目名称:cakephp,代码行数:33,代码来源:TestFixture.php

示例2: _schemaFromFields

 /**
  * Build the fixtures table schema from the fields property.
  *
  * @return void
  */
 protected function _schemaFromFields()
 {
     $this->_schema = new Table($this->table);
     foreach ($this->fields as $field => $data) {
         if ($field === '_constraints' || $field === '_indexes' || $field === '_options') {
             continue;
         }
         // Trigger errors on deprecated usage.
         if (is_array($data) && isset($data['key'])) {
             $msg = 'Usage of the `key` options in columns is not supported. Try using the upgrade shell to migrate your fixtures.';
             $msg .= ' You can download the upgrade shell from https://github.com/cakephp/upgrade.';
             trigger_error($msg, E_USER_NOTICE);
         }
         $this->_schema->addColumn($field, $data);
     }
     if (!empty($this->fields['_constraints'])) {
         foreach ($this->fields['_constraints'] as $name => $data) {
             $this->_schema->addConstraint($name, $data);
         }
     }
     if (!empty($this->fields['_indexes'])) {
         // Trigger errors on deprecated usage.
         if (empty($data['type'])) {
             $msg = 'Indexes must define a type. Try using the upgrade shell to migrate your fixtures.';
             $msg .= ' You can download the upgrade shell from https://github.com/cakephp/upgrade.';
             trigger_error($msg, E_USER_NOTICE);
         }
         foreach ($this->fields['_indexes'] as $name => $data) {
             $this->_schema->addIndex($name, $data);
         }
     }
     if (!empty($this->fields['_options'])) {
         $this->_schema->options($this->fields['_options']);
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:40,代码来源:TestFixture.php

示例3: _schemaFromFields

 /**
  * Build the fixtures table schema from the fields property.
  *
  * @return void
  */
 protected function _schemaFromFields()
 {
     $this->_schema = new Table($this->table);
     foreach ($this->fields as $field => $data) {
         if ($field === '_constraints' || $field === '_indexes' || $field === '_options') {
             continue;
         }
         $this->_schema->addColumn($field, $data);
     }
     if (!empty($this->fields['_constraints'])) {
         foreach ($this->fields['_constraints'] as $name => $data) {
             $this->_schema->addConstraint($name, $data);
         }
     }
     if (!empty($this->fields['_indexes'])) {
         foreach ($this->fields['_indexes'] as $name => $data) {
             $this->_schema->addIndex($name, $data);
         }
     }
     if (!empty($this->fields['_options'])) {
         $this->_schema->options($this->fields['_options']);
     }
 }
开发者ID:malhan23,项目名称:assignment-3,代码行数:28,代码来源:TestFixture.php

示例4: _generateSchema

 /**
  * Generates a string representation of a schema.
  *
  * @param \Cake\Database\Schema\Table $table Table schema
  * @return string fields definitions
  */
 protected function _generateSchema(Table $table)
 {
     $cols = $indexes = $constraints = [];
     foreach ($table->columns() as $field) {
         $fieldData = $table->column($field);
         $properties = implode(', ', $this->_values($fieldData));
         $cols[] = "        '{$field}' => [{$properties}],";
     }
     foreach ($table->indexes() as $index) {
         $fieldData = $table->index($index);
         $properties = implode(', ', $this->_values($fieldData));
         $indexes[] = "            '{$index}' => [{$properties}],";
     }
     foreach ($table->constraints() as $index) {
         $fieldData = $table->constraint($index);
         $properties = implode(', ', $this->_values($fieldData));
         $constraints[] = "            '{$index}' => [{$properties}],";
     }
     $options = $this->_values($table->options());
     $content = implode("\n", $cols) . "\n";
     if (!empty($indexes)) {
         $content .= "        '_indexes' => [\n" . implode("\n", $indexes) . "\n        ],\n";
     }
     if (!empty($constraints)) {
         $content .= "        '_constraints' => [\n" . implode("\n", $constraints) . "\n        ],\n";
     }
     if (!empty($options)) {
         foreach ($options as &$option) {
             $option = '            ' . $option;
         }
         $content .= "        '_options' => [\n" . implode(",\n", $options) . "\n        ],\n";
     }
     return "[\n{$content}    ]";
 }
开发者ID:AmuseXperience,项目名称:api,代码行数:40,代码来源:FixtureTask.php

示例5: createTableSql

 /**
  * {@inheritDoc}
  */
 public function createTableSql(Table $table, $columns, $constraints, $indexes)
 {
     $content = implode(",\n", array_merge($columns, $constraints, $indexes));
     $temporary = $table->temporary() ? ' TEMPORARY ' : ' ';
     $content = sprintf("CREATE%sTABLE `%s` (\n%s\n)", $temporary, $table->name(), $content);
     $options = $table->options();
     if (isset($options['engine'])) {
         $content .= sprintf(' ENGINE=%s', $options['engine']);
     }
     if (isset($options['charset'])) {
         $content .= sprintf(' DEFAULT CHARSET=%s', $options['charset']);
     }
     if (isset($options['collate'])) {
         $content .= sprintf(' COLLATE=%s', $options['collate']);
     }
     return [$content];
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:20,代码来源:MysqlSchema.php

示例6: Table

<?php

/**
 * Queued Tasks schema file
 *
 * @author David Yell <neon1024@gmail.com>
 * @author MGriesbach@gmail.com
 */
use Cake\Database\Schema\Table;
$t = new Table('queued_tasks');
$t->addColumn('id', ['type' => 'integer', 'length' => 10, 'null' => false, 'default' => null]);
$t->addColumn('job_type', ['type' => 'string', 'null' => false, 'length' => 45]);
$t->addColumn('data', ['type' => 'text', 'null' => true, 'default' => null]);
$t->addColumn('job_group', ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null]);
$t->addColumn('reference', ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null]);
$t->addColumn('created', ['type' => 'datetime', 'null' => true, 'default' => null]);
$t->addColumn('notbefore', ['type' => 'datetime', 'null' => true, 'default' => null]);
$t->addColumn('fetched', ['type' => 'datetime', 'null' => true, 'default' => null]);
$t->addColumn('progress', ['type' => 'float', 'length' => '3,2', 'null' => true, 'default' => null]);
$t->addColumn('status', ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null]);
$t->addColumn('completed', ['type' => 'datetime', 'null' => true, 'default' => null]);
$t->addColumn('failed', ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => 3]);
$t->addColumn('failure_message', ['type' => 'text', 'null' => true, 'default' => null]);
$t->addColumn('workerkey', ['type' => 'string', 'null' => true, 'length' => 45]);
$t->addConstraint('primary', ['type' => 'primary', 'columns' => ['id']]);
$t->options(['collate' => 'utf8_unicode_ci']);
开发者ID:dereuromark,项目名称:cakephp-queue,代码行数:26,代码来源:queued_tasks.php

示例7: convertOptionsDescription

 /**
  * {@inheritDoc}
  */
 public function convertOptionsDescription(Table $table, $row)
 {
     $table->options(['engine' => $row['Engine'], 'collation' => $row['Collation']]);
 }
开发者ID:voycey,项目名称:cakephp-salesforce,代码行数:7,代码来源:SalesforceSchema.php

示例8: _prepareSchema

 /**
  * Gets an schema instance for the given fixture class.
  *
  * @param string $fixtureClassName The fixture to be "converted"
  * @return \Cake\Database\Schema\Table Schema instance
  */
 protected function _prepareSchema($fixtureClassName)
 {
     $fixture = new $fixtureClassName();
     if (!empty($fixture->table)) {
         $tableName = $fixture->table;
     } else {
         $tableName = (string) Inflector::underscore(str_replace_last('Fixture', '', $fixtureClassName));
     }
     list($fields, $constraints, $indexes, $options) = $this->_prepareSchemaProperties($fixture);
     $schema = new TableSchema($tableName, $fields);
     foreach ($constraints as $name => $attrs) {
         $schema->addConstraint($name, $attrs);
     }
     foreach ($indexes as $name => $attrs) {
         $schema->addIndex($name, $attrs);
     }
     if (!empty($options)) {
         $schema->options($options);
     }
     return $schema;
 }
开发者ID:quickapps-plugins,项目名称:installer,代码行数:27,代码来源:DatabaseInstaller.php

示例9: testOptions

 /**
  * Test the options method.
  *
  * @return void
  */
 public function testOptions()
 {
     $table = new Table('articles');
     $options = ['engine' => 'InnoDB'];
     $return = $table->options($options);
     $this->assertInstanceOf('Cake\\Database\\Schema\\Table', $return);
     $this->assertEquals($options, $table->options());
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:13,代码来源:TableTest.php


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