Пример #1
0
 /**
  * Tells whether object can be converted to new engine type
  *
  * @param string $newEngineType
  * @throws Exception
  * @return mixed - true for success or array with restricted indexes and
  *         fields
  */
 public function checkEngineCompatibility($newEngineType)
 {
     $restrictedIndexes = array();
     $restrictedFields = array();
     $indexes = $this->_objectConfig->getIndexesConfig();
     $fields = $this->_objectConfig->getFieldsConfig();
     switch (strtolower($newEngineType)) {
         case 'myisam':
             break;
         case 'memory':
             foreach ($fields as $k => $v) {
                 $type = $v['db_type'];
                 if (in_array($type, self::$textTypes, true) || in_array($type, self::$blobTypes, true)) {
                     $restrictedFields[] = $k;
                 }
             }
             foreach ($indexes as $k => $v) {
                 if (isset($v['fulltext']) && $v['fulltext']) {
                     $restrictedIndexes[] = $k;
                 }
             }
             break;
         case 'innodb':
             foreach ($indexes as $k => $v) {
                 if (isset($v['fulltext']) && $v['fulltext']) {
                     $restrictedIndexes[] = $k;
                 }
             }
             break;
         default:
             throw new Exception('Unknown db engine type');
             break;
     }
     if (!empty($restrictedFields) || !empty($restrictedIndexes)) {
         return array('indexes' => $restrictedIndexes, 'fields' => $restrictedFields);
     } else {
         return true;
     }
 }