1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16: 17:
18: class CMysqlColumnSchema extends CDbColumnSchema
19: {
20: 21: 22: 23:
24: protected function ($dbType)
25: {
26: if(strncmp($dbType,'enum',4)===0)
27: $this->type='string';
28: elseif(strpos($dbType,'float')!==false || strpos($dbType,'double')!==false)
29: $this->type='double';
30: elseif(strpos($dbType,'bool')!==false)
31: $this->type='boolean';
32: elseif(strpos($dbType,'int')===0 && strpos($dbType,'unsigned')===false || preg_match('/(bit|tinyint|smallint|mediumint)/',$dbType))
33: $this->type='integer';
34: else
35: $this->type='string';
36: }
37:
38: 39: 40: 41: 42:
43: protected function ($defaultValue)
44: {
45: if(strncmp($this->dbType,'bit',3)===0)
46: $this->defaultValue=bindec(trim($defaultValue,'b\''));
47: elseif($this->dbType==='timestamp' && $defaultValue==='CURRENT_TIMESTAMP')
48: $this->defaultValue=null;
49: else
50: parent::extractDefault($defaultValue);
51: }
52:
53: 54: 55: 56:
57: protected function ($dbType)
58: {
59: if (strncmp($dbType, 'enum', 4)===0 && preg_match('/\(([\'"])(.*)\\1\)/',$dbType,$matches))
60: {
61:
62: $values = explode($matches[1].','.$matches[1], $matches[2]);
63: $size = 0;
64: foreach($values as $value)
65: {
66: if(($n=strlen($value)) > $size)
67: $size=$n;
68: }
69: $this->size = $this->precision = $size;
70: }
71: else
72: parent::extractLimit($dbType);
73: }
74: }
75: