コード例 #1
0
ファイル: Base.php プロジェクト: maitandat1507/DevHelper
 public function addDataPatch($table, array $patch)
 {
     if (!empty($patch['index'])) {
         if (!isset($patch['name'])) {
             $patch['name'] = implode('_', $patch['fields']);
         }
         $patchKey = 'index::' . $patch['name'];
         if (isset($patch['type'])) {
             $patch['type'] = strtoupper($patch['type']);
         } else {
             $patch['type'] = '';
         }
         if (!in_array($patch['type'], DevHelper_Generator_Db::getIndexTypes())) {
             $patch['type'] = 'NORMAL';
         }
         if (!isset($patch['fields'])) {
             throw new XenForo_Exception('addDataPatch(index=true) requires `fields`');
         }
         if (!is_array($patch['fields'])) {
             $patch['fields'] = array(strval($patch['fields']));
         }
     } else {
         $patch['name'] = DevHelper_Generator_Db::getFieldName($this, $this->_normalizeDbName($patch['name']));
         $patchKey = $patch['name'];
         if (!isset($patch['type'])) {
             throw new XenForo_Exception('addDataPatch() requires `type`');
         }
         $patch['type'] = strtolower($patch['type']);
         if (!in_array($patch['type'], DevHelper_Generator_Db::getDataTypes())) {
             $patch['type'] = XenForo_DataWriter::TYPE_SERIALIZED;
         }
     }
     $this->_dataPatches[$table][$patchKey] = $patch;
     return true;
 }
コード例 #2
0
ファイル: Base.php プロジェクト: hahuunguyen/DTUI_201105
 public function addDataPatch($table, array $field)
 {
     $field['name'] = DevHelper_Generator_Db::getFieldName($this, $this->_normalizeDbName($field['name']));
     $field['type'] = strtolower($field['type']);
     if (!in_array($field['type'], DevHelper_Generator_Db::getDataTypes())) {
         $field['type'] = XenForo_DataWriter::TYPE_SERIALIZED;
     }
     $this->_dataPatches[$table][$field['name']] = $field;
     return true;
 }