本文整理汇总了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']);
}
}
示例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']);
}
}
示例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']);
}
}
示例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} ]";
}
示例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];
}
示例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']);
示例7: convertOptionsDescription
/**
* {@inheritDoc}
*/
public function convertOptionsDescription(Table $table, $row)
{
$table->options(['engine' => $row['Engine'], 'collation' => $row['Collation']]);
}
示例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;
}
示例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());
}