1: <?php
2: /**
3: * COciColumnSchema class file.
4: *
5: * @author Ricardo Grana <rickgrana@yahoo.com.br>
6: * @link http://www.yiiframework.com/
7: * @copyright 2008-2013 Yii Software LLC
8: * @license http://www.yiiframework.com/license/
9: */
10:
11: /**
12: * COciColumnSchema class describes the column meta data of an Oracle table.
13: *
14: * @author Ricardo Grana <rickgrana@yahoo.com.br>
15: * @package system.db.schema.oci
16: */
17: class COciColumnSchema extends CDbColumnSchema
18: {
19: /**
20: * Extracts the PHP type from DB type.
21: * @param string $dbType DB type
22: * @return string
23: */
24: protected function extractOraType($dbType){
25: if(strpos($dbType,'FLOAT')!==false) return 'double';
26:
27: if (strpos($dbType,'NUMBER')!==false || strpos($dbType,'INTEGER')!==false)
28: {
29: if(strpos($dbType,'(') && preg_match('/\((.*)\)/',$dbType,$matches))
30: {
31: $values=explode(',',$matches[1]);
32: if(isset($values[1]) and (((int)$values[1]) > 0))
33: return 'double';
34: else
35: return 'integer';
36: }
37: else
38: return 'double';
39: }
40: else
41: return 'string';
42: }
43:
44: /**
45: * Extracts the PHP type from DB type.
46: * @param string $dbType DB type
47: */
48: protected function extractType($dbType)
49: {
50: $this->type=$this->extractOraType($dbType);
51: }
52:
53: /**
54: * Extracts the default value for the column.
55: * The value is typecasted to correct PHP type.
56: * @param mixed $defaultValue the default value obtained from metadata
57: */
58: protected function extractDefault($defaultValue)
59: {
60: if(stripos($defaultValue,'timestamp')!==false)
61: $this->defaultValue=null;
62: else
63: parent::extractDefault($defaultValue);
64: }
65: }
66: