1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16: 17:
18: class CPgsqlColumnSchema extends CDbColumnSchema
19: {
20: 21: 22: 23:
24: protected function ($dbType)
25: {
26: if(strpos($dbType,'[')!==false || strpos($dbType,'char')!==false || strpos($dbType,'text')!==false)
27: $this->type='string';
28: elseif(strpos($dbType,'bool')!==false)
29: $this->type='boolean';
30: elseif(preg_match('/(real|float|double)/',$dbType))
31: $this->type='double';
32: elseif(preg_match('/(integer|oid|serial|smallint)/',$dbType))
33: $this->type='integer';
34: else
35: $this->type='string';
36: }
37:
38: 39: 40: 41:
42: protected function ($dbType)
43: {
44: if(strpos($dbType,'('))
45: {
46: if (preg_match('/^time.*\((.*)\)/',$dbType,$matches))
47: {
48: $this->precision=(int)$matches[1];
49: }
50: elseif (preg_match('/\((.*)\)/',$dbType,$matches))
51: {
52: $values=explode(',',$matches[1]);
53: $this->size=$this->precision=(int)$values[0];
54: if(isset($values[1]))
55: $this->scale=(int)$values[1];
56: }
57: }
58: }
59:
60: 61: 62: 63: 64:
65: protected function ($defaultValue)
66: {
67: if($defaultValue==='true')
68: $this->defaultValue=true;
69: elseif($defaultValue==='false')
70: $this->defaultValue=false;
71: elseif(strpos($defaultValue,'nextval')===0)
72: $this->defaultValue=null;
73: elseif(preg_match('/^\'(.*)\'::/',$defaultValue,$matches))
74: $this->defaultValue=$this->typecast(str_replace("''","'",$matches[1]));
75: elseif(preg_match('/^(-?\d+(\.\d*)?)(::.*)?$/',$defaultValue,$matches))
76: $this->defaultValue=$this->typecast($matches[1]);
77:
78: }
79: }
80: