本文整理匯總了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);
}