本文整理汇总了PHP中DataType::check方法的典型用法代码示例。如果您正苦于以下问题:PHP DataType::check方法的具体用法?PHP DataType::check怎么用?PHP DataType::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataType
的用法示例。
在下文中一共展示了DataType::check方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCheck
/**
* test if the check method returns the correct values
*/
public function testCheck()
{
$types = array('bit', 'tinyint', 'bool', 'smallint', 'mediumint', 'int', 'bigint', 'float', 'double', 'decimal', 'char', 'varchar', 'tinytext', 'text', 'mediumtext', 'longtext', 'tinyblob', 'blob', 'mediumblob', 'longblob', 'binary', 'varbinary', 'enum', 'set', 'date', 'datetime', 'timestamp', 'time', 'year');
$options_bool = array(DataType::SUPPORTS_COLLATION, DataType::SUPPORTS_INDEX, DataType::SUPPORTS_UNIQUE, DataType::SUPPORTS_FULLTEXT, DataType::SUPPORTS_SIZE, DataType::SUPPORTS_SCALE, DataType::SUPPORTS_VALUES, DataType::SUPPORTS_UNSIGNED, DataType::SUPPORTS_UNSIGNED_ZEROFILL, DataType::SUPPORTS_ON_UPDATE_CURRENT_TIMESTAMP, DataType::SUPPORTS_AUTO_INCREMENT);
$options_string = array(DataType::GROUP, DataType::INPUT_TYPE);
foreach ($types as $type) {
foreach ($options_bool as $option) {
$this->assertType('bool', DataType::check($type, $option));
}
foreach ($options_string as $option) {
$this->assertType('string', DataType::check($type, $option));
}
}
}
示例2: getColumnDefinition
public function getColumnDefinition()
{
if (DataType::check($this->DATA_TYPE, DataType::SUPPORTS_COLLATION)) {
$collate = ' CHARACTER SET ' . Collation::getCharacterSet($this->COLLATION_NAME) . ' COLLATE ' . $this->COLLATION_NAME;
} else {
$collate = '';
}
if ($this->attribute) {
if ($this->attribute == 'unsigned' && DataType::check($this->DATA_TYPE, DataType::SUPPORTS_UNSIGNED) || $this->attribute == 'unsigned zerofill' && DataType::check($this->DATA_TYPE, DataType::SUPPORTS_UNSIGNED_ZEROFILL) || $this->attribute == 'on update current_timestamp' && DataType::check($this->DATA_TYPE, DataType::SUPPORTS_ON_UPDATE_CURRENT_TIMESTAMP)) {
$attribute = ' ' . $this->attribute;
} else {
$attribute = '';
}
} else {
$attribute = '';
}
if (strlen($this->COLUMN_DEFAULT) > 0 && $this->EXTRA != 'auto_increment') {
if ($this->DATA_TYPE == 'timestamp' && strtolower($this->COLUMN_DEFAULT) == 'current_timestamp') {
$defaultValue = 'CURRENT_TIMESTAMP';
} elseif ($this->DATA_TYPE == 'bit') {
if (preg_match('/b\'[01]+\'/', $this->COLUMN_DEFAULT)) {
$defaultValue = $this->COLUMN_DEFAULT;
} else {
$defaultValue = 'b' . self::$db->quoteValue($this->COLUMN_DEFAULT);
}
} else {
$defaultValue = self::$db->quoteValue($this->COLUMN_DEFAULT);
}
$default = ' DEFAULT ' . $defaultValue;
} else {
if ($this->getIsNullable() && $this->EXTRA != 'auto_increment') {
$default = ' DEFAULT NULL';
} else {
$default = '';
}
}
return trim(self::$db->quoteColumnName($this->COLUMN_NAME) . ' ' . $this->getColumnType() . $attribute . $collate . ($this->getIsNullable() ? ' NULL' : ' NOT NULL') . $default . ($this->EXTRA == 'auto_increment' ? ' AUTO_INCREMENT' : '') . ($this->createPrimaryKey ? ' PRIMARY KEY' : '') . ($this->createUniqueKey ? ' UNIQUE KEY' : '') . (strlen($this->COLUMN_COMMENT) ? ' COMMENT ' . self::$db->quoteValue($this->COLUMN_COMMENT) : ''));
}
示例3:
</a>
<?php
} else {
?>
<span class="icon">
<?php
echo Html::icon('key_unique', 16, true, 'core.uniqueKey');
?>
</span>
<?php
}
?>
</td>
<td>
<?php
if ($canAlter && DataType::check($column->DATA_TYPE, DataType::SUPPORTS_FULLTEXT)) {
?>
<a href="javascript:void(0)" onclick="tableStructure.addIndex1('fulltext', $(this).closest('tr').attr('id').substr(8))" class="icon">
<?php
echo Html::icon('key_fulltext', 16, false, 'core.fulltextIndex');
?>
</a>
<?php
} else {
?>
<span class="icon">
<?php
echo Html::icon('key_fulltext', 16, true, 'core.fulltextIndex');
?>
</span>
<?php