COciColumnSchema.php 1.5 KB

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