CCubridColumnSchema.php 1.3 KB

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