本文整理汇总了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::getDefaultValueDeclarationSQL方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPlatform::getDefaultValueDeclarationSQL方法的具体用法?PHP AbstractPlatform::getDefaultValueDeclarationSQL怎么用?PHP AbstractPlatform::getDefaultValueDeclarationSQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Platforms\AbstractPlatform
的用法示例。
在下文中一共展示了AbstractPlatform::getDefaultValueDeclarationSQL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetDefaultValueDeclarationSQLForIntegerTypes
public function testGetDefaultValueDeclarationSQLForIntegerTypes()
{
foreach (array('bigint', 'integer', 'smallint') as $type) {
$field = array('type' => Type::getType($type), 'default' => 1);
$this->assertEquals(' DEFAULT 1', $this->_platform->getDefaultValueDeclarationSQL($field));
}
}
示例2: getDefaultValueDeclarationSQL
/**
* {@inheritdoc}
*/
public function getDefaultValueDeclarationSQL($field)
{
// Unset the default value if the given field definition does not allow default values.
if ($field['type'] instanceof TextType || $field['type'] instanceof BlobType) {
$field['default'] = null;
}
return parent::getDefaultValueDeclarationSQL($field);
}
示例3: getDefaultValueDeclarationSQL
/**
* {@inheritDoc}
*/
public function getDefaultValueDeclarationSQL($field)
{
if (!empty($field['autoincrement'])) {
return '';
}
if (isset($field['version']) && $field['version']) {
if ((string) $field['type'] != "DateTime") {
$field['default'] = "1";
}
}
return parent::getDefaultValueDeclarationSQL($field);
}
示例4: getDefaultValueDeclarationSQL
public function getDefaultValueDeclarationSQL($field)
{
if (isset($field['notnull']) && $field['notnull'] && !isset($field['default'])) {
if (in_array((string) $field['type'], array("Integer", "BigInteger", "SmallInteger"))) {
$field['default'] = 0;
} else {
if ((string) $field['type'] == "DateTime") {
$field['default'] = "00-00-00 00:00:00";
} else {
if ((string) $field['type'] == "Date") {
$field['default'] = "00-00-00";
} else {
if ((string) $field['type'] == "Time") {
$field['default'] = "00:00:00";
} else {
$field['default'] = '';
}
}
}
}
}
unset($field['default']);
// @todo this needs fixing
if (isset($field['version']) && $field['version']) {
if ((string) $field['type'] != "DateTime") {
$field['default'] = "1";
}
}
return parent::getDefaultValueDeclarationSQL($field);
}