Пример #1
0
 /**
  * Extracts size, precision and scale information from column's DB type.
  * @param string $dbType the column's DB type
  */
 protected function extractLimit($dbType)
 {
     if (strncmp($dbType, 'enum', 4) === 0 && preg_match('/\\((.*)\\)/', $dbType, $matches)) {
         $values = explode(',', $matches[1]);
         $size = 0;
         foreach ($values as $value) {
             if (($n = strlen($value)) > $size) {
                 $size = $n;
             }
         }
         $this->size = $this->precision = $size - 2;
     } else {
         parent::extractLimit($dbType);
     }
 }
Пример #2
0
 /**
  * Extracts size, precision and scale information from column's DB type.
  * @param string $dbType the column's DB type
  */
 protected function extractLimit($dbType)
 {
     if (strncmp($dbType, 'enum', 4) === 0 && preg_match('/\\(([\'"])(.*)\\1\\)/', $dbType, $matches)) {
         // explode by (single or double) quote and comma (ENUM values may contain commas)
         $values = explode($matches[1] . ',' . $matches[1], $matches[2]);
         $size = 0;
         foreach ($values as $value) {
             if (($n = strlen($value)) > $size) {
                 $size = $n;
             }
         }
         $this->size = $this->precision = $size;
     } else {
         parent::extractLimit($dbType);
     }
 }