1: <?php
2: /**
3: * CSqliteColumnSchema class file.
4: *
5: * @author Qiang Xue <qiang.xue@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: * CSqliteColumnSchema class describes the column meta data of a SQLite table.
13: *
14: * @author Qiang Xue <qiang.xue@gmail.com>
15: * @package system.db.schema.sqlite
16: * @since 1.0
17: */
18: class CSqliteColumnSchema extends CDbColumnSchema
19: {
20: /**
21: * Extracts the default value for the column.
22: * The value is typecasted to correct PHP type.
23: * @param mixed $defaultValue the default value obtained from metadata
24: */
25: protected function extractDefault($defaultValue)
26: {
27: if($this->dbType==='timestamp' && $defaultValue==='CURRENT_TIMESTAMP')
28: $this->defaultValue=null;
29: else
30: $this->defaultValue=$this->typecast(strcasecmp($defaultValue,'null') ? $defaultValue : null);
31:
32: if($this->type==='string' && $this->defaultValue!==null) // PHP 5.2.6 adds single quotes while 5.2.0 doesn't
33: $this->defaultValue=trim($this->defaultValue,"'\"");
34: }
35: }
36: