-
Notifications
You must be signed in to change notification settings - Fork 8
/
CFirebirdColumnSchema.php
60 lines (56 loc) · 1.87 KB
/
CFirebirdColumnSchema.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* CFirebirdColumnSchema class file.
*
* @author idle sign <[email protected]>
* @updated by Ricardo Obregón <[email protected]>
* @updated by Edgard messias <[email protected]>
*/
/**
* CFirebirdColumnSchema class describes the column meta data of a Firebird table.
*
* @author idle sign <[email protected]>
* @updated by Ricardo Obregón <[email protected]>
* @updated by Edgard messias <[email protected]>
*/
class CFirebirdColumnSchema extends CDbColumnSchema
{
/**
* Extracts the PHP type from DB type.
* @param string DB type
*/
protected function extractType($dbType)
{
// @todo Need to handle more data types here.
//Types timestamp, date, time, text, blob are string in PHP
if (stripos($dbType, 'int') !== false || stripos($dbType, 'quad') !== false) {
$this->type = 'integer';
} elseif (stripos($dbType, 'bool') !== false) {
$this->type = 'boolean';
} elseif (preg_match('/(numeric|decimal|floa|doub)/i', $dbType)) {
$this->type = 'double';
} else {
$this->type = 'string';
}
}
/**
* Extracts the default value for the column.
* The value is typecasted to correct PHP type.
* @param mixed the default value obtained from metadata
*/
protected function extractDefault($defaultValue)
{
/*
* handle CURRENT_DATE/TIME/TIMESTAMP with optional precision
* @todo handle context variable 'NOW'
* ref. http://www.firebirdsql.org/refdocs/langrefupd25-variables.html
*/
if (preg_match('/(CURRENT_|NULL|TODAY|TOMORROW|YESTERDAY)/i', $defaultValue)) {
$this->defaultValue = null;
} elseif ($defaultValue == "''") {
$this->defaultValue = '';
} else {
parent::extractDefault($defaultValue);
}
}
}