1: <?php
2: /**
3: * CCubridColumnSchema class file.
4: *
5: * @author Esen Sagynov <kadismal@gmail.com>
6: * @link http://www.yiiframework.com/
7: * @copyright 2008-2013 Yii Software LLC
8: * @license http://www.yiiframework.com/license/
9: */
10:
11: /**
12: * CCubridColumnSchema class describes the column meta data of a CUBRID table.
13: *
14: * @author Esen Sagynov <kadismal@gmail.com>
15: * @package system.db.schema.cubrid
16: * @since 1.1.16
17: */
18: class CCubridColumnSchema extends CDbColumnSchema
19: {
20: /**
21: * Extracts the PHP type from DB type.
22: * @param string $dbType DB type
23: */
24: protected function extractType($dbType)
25: {
26: if(preg_match('/(FLO|REA|DOU|NUM|DEC)/',$dbType))
27: $this->type='double';
28: // The following "bool" and 'boolean" are for future compatibility.
29: // As of CUBRID 9.0, they are not supported.
30: elseif(strpos($dbType,'BOOL')!==false)
31: $this->type='boolean';
32: elseif(preg_match('/(INT|BIT|SMA|SHO|NUM)/',$dbType))
33: $this->type='integer';
34: else
35: $this->type='string';
36: }
37:
38: /**
39: * Extracts the default value for the column.
40: * The value is typecasted to correct PHP type.
41: * @param mixed $defaultValue the default value obtained from metadata
42: */
43: protected function extractDefault($defaultValue)
44: {
45: if($this->dbType==='TIMESTAMP' && $defaultValue==='CURRENT_TIMESTAMP')
46: $this->defaultValue=null;
47: else
48: parent::extractDefault($defaultValue);
49: }
50: }
51: