@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -58,8 +60,7 @@ discard block |
||
58 | 60 | if (is_array($list)) |
59 | 61 | { |
60 | 62 | $list = array_merge(array($currency), $list); |
61 | - } |
|
62 | - else |
|
63 | + } else |
|
63 | 64 | { |
64 | 65 | $list = array($currency); |
65 | 66 | } |
@@ -105,8 +106,7 @@ discard block |
||
105 | 106 | if (!empty ($field_def['sort_on'])) |
106 | 107 | { |
107 | 108 | $order_by = $layout_def['table_alias'].".".$field_def['sort_on']; |
108 | - } |
|
109 | - else |
|
109 | + } else |
|
110 | 110 | { |
111 | 111 | $order_by = $this->_get_column_select($layout_def); |
112 | 112 | } |
@@ -114,8 +114,7 @@ discard block |
||
114 | 114 | if (empty ($layout_def['sort_dir']) || $layout_def['sort_dir'] == 'a') |
115 | 115 | { |
116 | 116 | $order_dir = "ASC"; |
117 | - } |
|
118 | - else |
|
117 | + } else |
|
119 | 118 | { |
120 | 119 | $order_dir = "DESC"; |
121 | 120 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -69,8 +71,7 @@ discard block |
||
69 | 71 | global $app_list_strings; |
70 | 72 | if (empty($value)) { |
71 | 73 | $value = $app_list_strings['dom_switch_bool']['off']; |
72 | - } |
|
73 | - else { |
|
74 | + } else { |
|
74 | 75 | $value = $app_list_strings['dom_switch_bool']['on']; |
75 | 76 | } |
76 | 77 | return $value; |
@@ -97,11 +98,9 @@ discard block |
||
97 | 98 | $yes = $no = $default = ''; |
98 | 99 | if (isset($layout_def['input_name0']) && $layout_def['input_name0'] == 1) { |
99 | 100 | $yes = ' selected="selected"'; |
100 | - } |
|
101 | - elseif (isset($layout_def['input_name0']) && $layout_def['input_name0'] == 'off') { |
|
101 | + } elseif (isset($layout_def['input_name0']) && $layout_def['input_name0'] == 'off') { |
|
102 | 102 | $no = ' selected="selected"'; |
103 | - } |
|
104 | - else { |
|
103 | + } else { |
|
105 | 104 | $default = ' selected="selected"'; |
106 | 105 | } |
107 | 106 |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -65,18 +67,24 @@ discard block |
||
65 | 67 | } |
66 | 68 | |
67 | 69 | $additionalFormFields = array(); |
68 | - if(isset($defines['focus']->billing_address_street)) |
|
69 | - $additionalFormFields['primary_address_street'] = $defines['focus']->billing_address_street; |
|
70 | - if(isset($defines['focus']->billing_address_city)) |
|
71 | - $additionalFormFields['primary_address_city'] = $defines['focus']->billing_address_city; |
|
72 | - if(isset($defines['focus']->billing_address_state)) |
|
73 | - $additionalFormFields['primary_address_state'] = $defines['focus']->billing_address_state; |
|
74 | - if(isset($defines['focus']->billing_address_country)) |
|
75 | - $additionalFormFields['primary_address_country'] = $defines['focus']->billing_address_country; |
|
76 | - if(isset($defines['focus']->billing_address_postalcode)) |
|
77 | - $additionalFormFields['primary_address_postalcode'] = $defines['focus']->billing_address_postalcode; |
|
78 | - if(isset($defines['focus']->phone_office)) |
|
79 | - $additionalFormFields['phone_work'] = $defines['focus']->phone_office; |
|
70 | + if(isset($defines['focus']->billing_address_street)) { |
|
71 | + $additionalFormFields['primary_address_street'] = $defines['focus']->billing_address_street; |
|
72 | + } |
|
73 | + if(isset($defines['focus']->billing_address_city)) { |
|
74 | + $additionalFormFields['primary_address_city'] = $defines['focus']->billing_address_city; |
|
75 | + } |
|
76 | + if(isset($defines['focus']->billing_address_state)) { |
|
77 | + $additionalFormFields['primary_address_state'] = $defines['focus']->billing_address_state; |
|
78 | + } |
|
79 | + if(isset($defines['focus']->billing_address_country)) { |
|
80 | + $additionalFormFields['primary_address_country'] = $defines['focus']->billing_address_country; |
|
81 | + } |
|
82 | + if(isset($defines['focus']->billing_address_postalcode)) { |
|
83 | + $additionalFormFields['primary_address_postalcode'] = $defines['focus']->billing_address_postalcode; |
|
84 | + } |
|
85 | + if(isset($defines['focus']->phone_office)) { |
|
86 | + $additionalFormFields['phone_work'] = $defines['focus']->phone_office; |
|
87 | + } |
|
80 | 88 | |
81 | 89 | |
82 | 90 | $button = $this->_get_form($defines, $additionalFormFields); |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -111,7 +113,7 @@ discard block |
||
111 | 113 | if($layout_def['ListView']) { |
112 | 114 | return "<a href=\"javascript:sub_p_rem('$subpanel', '$linked_field'" .", '$record', $refresh_page);\"" |
113 | 115 | . ' class="listViewTdToolsS1"' . " onclick=\"return sp_rem_conf();\"" . ">$icon_remove_text</a>"; |
114 | - }else{ |
|
116 | + } else{ |
|
115 | 117 | return ''; |
116 | 118 | } |
117 | 119 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -59,8 +61,7 @@ discard block |
||
59 | 61 | if(isset($layout_def['varname'])) |
60 | 62 | { |
61 | 63 | $key = strtoupper($layout_def['varname']); |
62 | - } |
|
63 | - else |
|
64 | + } else |
|
64 | 65 | { |
65 | 66 | $key = $this->_get_column_alias($layout_def); |
66 | 67 | $key = strtoupper($key); |
@@ -77,8 +78,7 @@ discard block |
||
77 | 78 | if(empty($layout_def['target_module'])) |
78 | 79 | { |
79 | 80 | $module = $layout_def['module']; |
80 | - } |
|
81 | - else |
|
81 | + } else |
|
82 | 82 | { |
83 | 83 | $module = $layout_def['target_module']; |
84 | 84 | } |
@@ -87,8 +87,7 @@ discard block |
||
87 | 87 | if(empty($layout_def['target_record_key'])) |
88 | 88 | { |
89 | 89 | $record = $layout_def['fields']['ID']; |
90 | - } |
|
91 | - else |
|
90 | + } else |
|
92 | 91 | { |
93 | 92 | $record_key = strtoupper($layout_def['target_record_key']); |
94 | 93 | $record = $layout_def['fields'][$record_key]; |
@@ -56,8 +56,9 @@ discard block |
||
56 | 56 | } |
57 | 57 | $temp_mod_strings = $mod_strings; |
58 | 58 | $lang = $current_language; |
59 | - if(empty($lang)) |
|
60 | - $lang = $GLOBALS['sugar_config']['default_language']; |
|
59 | + if(empty($lang)) { |
|
60 | + $lang = $GLOBALS['sugar_config']['default_language']; |
|
61 | + } |
|
61 | 62 | static $createdModules = array(); |
62 | 63 | if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){ |
63 | 64 | $loaded_mod_strings = array(); |
@@ -84,7 +85,9 @@ discard block |
||
84 | 85 | } |
85 | 86 | |
86 | 87 | static function addTemplate($module, $lang, $template){ |
87 | - if($template == 'default')$template = 'basic'; |
|
88 | + if($template == 'default') { |
|
89 | + $template = 'basic'; |
|
90 | + } |
|
88 | 91 | $templates = array(); |
89 | 92 | $fields = array(); |
90 | 93 | if(empty($templates[$template])){ |
@@ -92,7 +95,7 @@ discard block |
||
92 | 95 | if(file_exists($path)){ |
93 | 96 | require($path); |
94 | 97 | $templates[$template] = $mod_strings; |
95 | - }else{ |
|
98 | + } else{ |
|
96 | 99 | $path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php'; |
97 | 100 | if(file_exists($path)){ |
98 | 101 | require($path); |
@@ -106,8 +109,9 @@ discard block |
||
106 | 109 | } |
107 | 110 | |
108 | 111 | static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
109 | - if(empty($lang)) |
|
110 | - $lang = $GLOBALS['sugar_config']['default_language']; |
|
112 | + if(empty($lang)) { |
|
113 | + $lang = $GLOBALS['sugar_config']['default_language']; |
|
114 | + } |
|
111 | 115 | |
112 | 116 | $file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php'); |
113 | 117 | write_array_to_file('mod_strings',$loaded_mod_strings, $file); |
@@ -140,7 +144,9 @@ discard block |
||
140 | 144 | $cache_dir = sugar_cached('modules/'); |
141 | 145 | if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
142 | 146 | while(($entry = readdir($dir)) !== false) { |
143 | - if ($entry == "." || $entry == "..") continue; |
|
147 | + if ($entry == "." || $entry == "..") { |
|
148 | + continue; |
|
149 | + } |
|
144 | 150 | foreach($languages as $clean_lang) { |
145 | 151 | LanguageManager::_clearCache($entry, $clean_lang); |
146 | 152 | } |
@@ -188,8 +194,9 @@ discard block |
||
188 | 194 | if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){ |
189 | 195 | $object = $GLOBALS['beanList'][$module]; |
190 | 196 | |
191 | - if ($object == 'aCase') |
|
192 | - $object = 'Case'; |
|
197 | + if ($object == 'aCase') { |
|
198 | + $object = 'Case'; |
|
199 | + } |
|
193 | 200 | |
194 | 201 | if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){ |
195 | 202 | $templates = $GLOBALS["dictionary"]["$object"]["templates"]; |
@@ -212,8 +219,7 @@ discard block |
||
212 | 219 | if(!empty($mod_strings)){ |
213 | 220 | if (function_exists('sugarArrayMergeRecursive')){ |
214 | 221 | $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings); |
215 | - } |
|
216 | - else{ |
|
222 | + } else{ |
|
217 | 223 | $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings); |
218 | 224 | } |
219 | 225 | } |
@@ -222,8 +228,9 @@ discard block |
||
222 | 228 | |
223 | 229 | //great! now that we have loaded all of our vardefs. |
224 | 230 | //let's go save them to the cache file. |
225 | - if(!empty($loaded_mod_strings)) |
|
226 | - LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
231 | + if(!empty($loaded_mod_strings)) { |
|
232 | + LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
233 | + } |
|
227 | 234 | } |
228 | 235 | |
229 | 236 | static function loadModuleLanguage($module, $lang, $refresh=false){ |
@@ -256,8 +263,9 @@ discard block |
||
256 | 263 | require $cachedfile; |
257 | 264 | |
258 | 265 | // now that we hae loaded the data from disk, put it in the cache. |
259 | - if(!empty($mod_strings)) |
|
260 | - sugar_cache_put($key,$mod_strings); |
|
266 | + if(!empty($mod_strings)) { |
|
267 | + sugar_cache_put($key,$mod_strings); |
|
268 | + } |
|
261 | 269 | if(!empty($_SESSION['translation_mode'])){ |
262 | 270 | $mod_strings = array_map('translated_prefix', $mod_strings); |
263 | 271 | } |
@@ -292,10 +300,11 @@ discard block |
||
292 | 300 | unlink($file); |
293 | 301 | } |
294 | 302 | |
295 | - if( empty($GLOBALS['sugar_config']['js_lang_version']) ) |
|
296 | - $GLOBALS['sugar_config']['js_lang_version'] = 1; |
|
297 | - else |
|
298 | - $GLOBALS['sugar_config']['js_lang_version'] += 1; |
|
303 | + if( empty($GLOBALS['sugar_config']['js_lang_version']) ) { |
|
304 | + $GLOBALS['sugar_config']['js_lang_version'] = 1; |
|
305 | + } else { |
|
306 | + $GLOBALS['sugar_config']['js_lang_version'] += 1; |
|
307 | + } |
|
299 | 308 | |
300 | 309 | write_array_to_file( "sugar_config", $GLOBALS['sugar_config'], "config.php"); |
301 | 310 | } |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -153,16 +155,18 @@ discard block |
||
153 | 155 | { |
154 | 156 | global $sugar_config; |
155 | 157 | |
156 | - if (is_null($configOptions)) |
|
157 | - $configOptions = $sugar_config['dbconfig']; |
|
158 | + if (is_null($configOptions)) { |
|
159 | + $configOptions = $sugar_config['dbconfig']; |
|
160 | + } |
|
158 | 161 | |
159 | 162 | //set the connections parameters |
160 | 163 | $connect_param = ''; |
161 | 164 | $configOptions['db_host_instance'] = trim($configOptions['db_host_instance']); |
162 | - if (empty($configOptions['db_host_instance'])) |
|
163 | - $connect_param = $configOptions['db_host_name']; |
|
164 | - else |
|
165 | - $connect_param = $configOptions['db_host_name']."\\".$configOptions['db_host_instance']; |
|
165 | + if (empty($configOptions['db_host_instance'])) { |
|
166 | + $connect_param = $configOptions['db_host_name']; |
|
167 | + } else { |
|
168 | + $connect_param = $configOptions['db_host_name']."\\".$configOptions['db_host_instance']; |
|
169 | + } |
|
166 | 170 | |
167 | 171 | /* |
168 | 172 | * Don't try to specifically use a persistent connection |
@@ -192,8 +196,9 @@ discard block |
||
192 | 196 | } |
193 | 197 | } |
194 | 198 | |
195 | - if($this->checkError('Could Not Connect:', $dieOnError)) |
|
196 | - $GLOBALS['log']->info("connected to db"); |
|
199 | + if($this->checkError('Could Not Connect:', $dieOnError)) { |
|
200 | + $GLOBALS['log']->info("connected to db"); |
|
201 | + } |
|
197 | 202 | |
198 | 203 | sqlsrv_query($this->database, 'SET DATEFORMAT mdy'); |
199 | 204 | |
@@ -245,8 +250,9 @@ discard block |
||
245 | 250 | |
246 | 251 | foreach ( sqlsrv_field_metadata($result) as $fieldMetadata ) { |
247 | 252 | $key = $fieldMetadata['Name']; |
248 | - if($make_lower_case==true) |
|
249 | - $key = strtolower($key); |
|
253 | + if($make_lower_case==true) { |
|
254 | + $key = strtolower($key); |
|
255 | + } |
|
250 | 256 | |
251 | 257 | $field_array[] = $key; |
252 | 258 | } |
@@ -259,7 +265,9 @@ discard block |
||
259 | 265 | */ |
260 | 266 | public function fetchRow($result) |
261 | 267 | { |
262 | - if (empty($result)) return false; |
|
268 | + if (empty($result)) { |
|
269 | + return false; |
|
270 | + } |
|
263 | 271 | |
264 | 272 | $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC); |
265 | 273 | if (empty($row)) { |
@@ -284,11 +292,12 @@ discard block |
||
284 | 292 | */ |
285 | 293 | public function convert($string, $type, array $additional_parameters = array()) |
286 | 294 | { |
287 | - if ( $type == 'datetime') |
|
288 | - // see http://msdn.microsoft.com/en-us/library/ms187928.aspx for details |
|
295 | + if ( $type == 'datetime') { |
|
296 | + // see http://msdn.microsoft.com/en-us/library/ms187928.aspx for details |
|
289 | 297 | return "CONVERT(datetime,$string,120)"; |
290 | - else |
|
291 | - return parent::convert($string, $type, $additional_parameters); |
|
298 | + } else { |
|
299 | + return parent::convert($string, $type, $additional_parameters); |
|
300 | + } |
|
292 | 301 | } |
293 | 302 | |
294 | 303 | /** |
@@ -330,8 +339,9 @@ discard block |
||
330 | 339 | */ |
331 | 340 | protected function freeDbResult($dbResult) |
332 | 341 | { |
333 | - if(!empty($dbResult)) |
|
334 | - sqlsrv_free_stmt($dbResult); |
|
342 | + if(!empty($dbResult)) { |
|
343 | + sqlsrv_free_stmt($dbResult); |
|
344 | + } |
|
335 | 345 | } |
336 | 346 | |
337 | 347 | |
@@ -377,14 +387,12 @@ discard block |
||
377 | 387 | if ( $row['TYPE_NAME'] == 'decimal' ) { |
378 | 388 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
379 | 389 | $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
380 | - } |
|
381 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
390 | + } elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
382 | 391 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
383 | 392 | if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) { |
384 | 393 | $columns[$column_name]['len']='max'; |
385 | 394 | } |
386 | - } |
|
387 | - elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
|
395 | + } elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
|
388 | 396 | $columns[$column_name]['len']=strtolower($row['LENGTH']); |
389 | 397 | } |
390 | 398 | if ( stristr($row['TYPE_NAME'],'identity') ) { |
@@ -392,8 +400,9 @@ discard block |
||
392 | 400 | $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME'])); |
393 | 401 | } |
394 | 402 | |
395 | - if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) |
|
396 | - $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
|
403 | + if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) { |
|
404 | + $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
|
405 | + } |
|
397 | 406 | |
398 | 407 | $column_def = 1; |
399 | 408 | if ( strtolower($tablename) == 'relationships' ) { |
@@ -402,12 +411,13 @@ discard block |
||
402 | 411 | if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
403 | 412 | $matches = array(); |
404 | 413 | $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES); |
405 | - if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) |
|
406 | - $columns[$column_name]['default'] = $matches[1]; |
|
407 | - elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) |
|
408 | - $columns[$column_name]['default'] = $matches[1]; |
|
409 | - else |
|
410 | - $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
|
414 | + if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) { |
|
415 | + $columns[$column_name]['default'] = $matches[1]; |
|
416 | + } elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) { |
|
417 | + $columns[$column_name]['default'] = $matches[1]; |
|
418 | + } else { |
|
419 | + $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
|
420 | + } |
|
411 | 421 | } |
412 | 422 | } |
413 | 423 | return $columns; |
@@ -495,7 +505,9 @@ discard block |
||
495 | 505 | public function lastDbError() |
496 | 506 | { |
497 | 507 | $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); |
498 | - if(empty($errors)) return false; |
|
508 | + if(empty($errors)) { |
|
509 | + return false; |
|
510 | + } |
|
499 | 511 | global $app_strings; |
500 | 512 | if (empty($app_strings) |
501 | 513 | or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -185,8 +187,9 @@ discard block |
||
185 | 187 | $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
186 | 188 | |
187 | 189 | |
188 | - if($keepResult) |
|
189 | - $this->lastResult = $result; |
|
190 | + if($keepResult) { |
|
191 | + $this->lastResult = $result; |
|
192 | + } |
|
190 | 193 | |
191 | 194 | $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError); |
192 | 195 | return $result; |
@@ -236,8 +239,9 @@ discard block |
||
236 | 239 | */ |
237 | 240 | protected function freeDbResult($dbResult) |
238 | 241 | { |
239 | - if(!empty($dbResult)) |
|
240 | - mysql_free_result($dbResult); |
|
242 | + if(!empty($dbResult)) { |
|
243 | + mysql_free_result($dbResult); |
|
244 | + } |
|
241 | 245 | } |
242 | 246 | |
243 | 247 | |
@@ -260,8 +264,9 @@ discard block |
||
260 | 264 | { |
261 | 265 | $start = (int)$start; |
262 | 266 | $count = (int)$count; |
263 | - if ($start < 0) |
|
264 | - $start = 0; |
|
267 | + if ($start < 0) { |
|
268 | + $start = 0; |
|
269 | + } |
|
265 | 270 | $GLOBALS['log']->debug('Limit Query:' . $sql. ' Start: ' .$start . ' count: ' . $count); |
266 | 271 | |
267 | 272 | $sql = "$sql LIMIT $start,$count"; |
@@ -286,21 +291,27 @@ discard block |
||
286 | 291 | $result = $this->query('EXPLAIN ' . $sql); |
287 | 292 | $badQuery = array(); |
288 | 293 | while ($row = $this->fetchByAssoc($result)) { |
289 | - if (empty($row['table'])) |
|
290 | - continue; |
|
294 | + if (empty($row['table'])) { |
|
295 | + continue; |
|
296 | + } |
|
291 | 297 | $badQuery[$row['table']] = ''; |
292 | - if (strtoupper($row['type']) == 'ALL') |
|
293 | - $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
294 | - if (empty($row['key'])) |
|
295 | - $badQuery[$row['table']] .= ' No Index Key Used;'; |
|
296 | - if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) |
|
297 | - $badQuery[$row['table']] .= ' Using FileSort;'; |
|
298 | - if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using temporary') > 0) |
|
299 | - $badQuery[$row['table']] .= ' Using Temporary Table;'; |
|
298 | + if (strtoupper($row['type']) == 'ALL') { |
|
299 | + $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
300 | + } |
|
301 | + if (empty($row['key'])) { |
|
302 | + $badQuery[$row['table']] .= ' No Index Key Used;'; |
|
303 | + } |
|
304 | + if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) { |
|
305 | + $badQuery[$row['table']] .= ' Using FileSort;'; |
|
306 | + } |
|
307 | + if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using temporary') > 0) { |
|
308 | + $badQuery[$row['table']] .= ' Using Temporary Table;'; |
|
309 | + } |
|
300 | 310 | } |
301 | 311 | |
302 | - if ( empty($badQuery) ) |
|
303 | - return true; |
|
312 | + if ( empty($badQuery) ) { |
|
313 | + return true; |
|
314 | + } |
|
304 | 315 | |
305 | 316 | foreach($badQuery as $table=>$data ){ |
306 | 317 | if(!empty($data)){ |
@@ -308,8 +319,7 @@ discard block |
||
308 | 319 | if(!empty($GLOBALS['sugar_config']['check_query_log'])){ |
309 | 320 | $GLOBALS['log']->fatal($sql); |
310 | 321 | $GLOBALS['log']->fatal('CHECK QUERY:' .$warning); |
311 | - } |
|
312 | - else{ |
|
322 | + } else{ |
|
313 | 323 | $GLOBALS['log']->warn('CHECK QUERY:' .$warning); |
314 | 324 | } |
315 | 325 | } |
@@ -333,14 +343,18 @@ discard block |
||
333 | 343 | $matches = array(); |
334 | 344 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*)\)|)( unsigned)?/i', $row['Type'], $matches); |
335 | 345 | $columns[$name]['type']=strtolower($matches[1][0]); |
336 | - if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) |
|
337 | - $columns[$name]['len']=strtolower($matches[2][0]); |
|
338 | - if ( stristr($row['Extra'],'auto_increment') ) |
|
339 | - $columns[$name]['auto_increment'] = '1'; |
|
340 | - if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) |
|
341 | - $columns[$name]['required'] = 'true'; |
|
342 | - if (!empty($row['Default']) ) |
|
343 | - $columns[$name]['default'] = $row['Default']; |
|
346 | + if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) { |
|
347 | + $columns[$name]['len']=strtolower($matches[2][0]); |
|
348 | + } |
|
349 | + if ( stristr($row['Extra'],'auto_increment') ) { |
|
350 | + $columns[$name]['auto_increment'] = '1'; |
|
351 | + } |
|
352 | + if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) { |
|
353 | + $columns[$name]['required'] = 'true'; |
|
354 | + } |
|
355 | + if (!empty($row['Default']) ) { |
|
356 | + $columns[$name]['default'] = $row['Default']; |
|
357 | + } |
|
344 | 358 | } |
345 | 359 | return $columns; |
346 | 360 | } |
@@ -352,17 +366,20 @@ discard block |
||
352 | 366 | { |
353 | 367 | $field_array = array(); |
354 | 368 | |
355 | - if(empty($result)) |
|
356 | - return 0; |
|
369 | + if(empty($result)) { |
|
370 | + return 0; |
|
371 | + } |
|
357 | 372 | |
358 | 373 | $fields = mysql_num_fields($result); |
359 | 374 | for ($i=0; $i < $fields; $i++) { |
360 | 375 | $meta = mysql_fetch_field($result, $i); |
361 | - if (!$meta) |
|
362 | - return array(); |
|
376 | + if (!$meta) { |
|
377 | + return array(); |
|
378 | + } |
|
363 | 379 | |
364 | - if($make_lower_case == true) |
|
365 | - $meta->name = strtolower($meta->name); |
|
380 | + if($make_lower_case == true) { |
|
381 | + $meta->name = strtolower($meta->name); |
|
382 | + } |
|
366 | 383 | |
367 | 384 | $field_array[] = $meta->name; |
368 | 385 | } |
@@ -375,7 +392,9 @@ discard block |
||
375 | 392 | */ |
376 | 393 | public function fetchRow($result) |
377 | 394 | { |
378 | - if (empty($result)) return false; |
|
395 | + if (empty($result)) { |
|
396 | + return false; |
|
397 | + } |
|
379 | 398 | |
380 | 399 | return mysql_fetch_assoc($result); |
381 | 400 | } |
@@ -419,7 +438,9 @@ discard block |
||
419 | 438 | |
420 | 439 | if ($this->getDatabase()) { |
421 | 440 | $result = $this->query("SHOW TABLES LIKE ".$this->quoted($tableName)); |
422 | - if(empty($result)) return false; |
|
441 | + if(empty($result)) { |
|
442 | + return false; |
|
443 | + } |
|
423 | 444 | $row = $this->fetchByAssoc($result); |
424 | 445 | return !empty($row); |
425 | 446 | } |
@@ -474,8 +495,9 @@ discard block |
||
474 | 495 | { |
475 | 496 | global $sugar_config; |
476 | 497 | |
477 | - if(is_null($configOptions)) |
|
478 | - $configOptions = $sugar_config['dbconfig']; |
|
498 | + if(is_null($configOptions)) { |
|
499 | + $configOptions = $sugar_config['dbconfig']; |
|
500 | + } |
|
479 | 501 | |
480 | 502 | if ($this->getOption('persistent')) { |
481 | 503 | $this->database = @mysql_pconnect( |
@@ -528,8 +550,9 @@ discard block |
||
528 | 550 | } |
529 | 551 | mysql_query($names, $this->database); |
530 | 552 | |
531 | - if(!$this->checkError('Could Not Connect:', $dieOnError)) |
|
532 | - $GLOBALS['log']->info("connected to db"); |
|
553 | + if(!$this->checkError('Could Not Connect:', $dieOnError)) { |
|
554 | + $GLOBALS['log']->info("connected to db"); |
|
555 | + } |
|
533 | 556 | $this->connectOptions = $configOptions; |
534 | 557 | |
535 | 558 | $GLOBALS['log']->info("Connect:".$this->database); |
@@ -546,8 +569,9 @@ discard block |
||
546 | 569 | { |
547 | 570 | $sql = parent::repairTableParams($tablename,$fielddefs,$indices,false,$engine); |
548 | 571 | |
549 | - if ( $sql == '' ) |
|
550 | - return ''; |
|
572 | + if ( $sql == '' ) { |
|
573 | + return ''; |
|
574 | + } |
|
551 | 575 | |
552 | 576 | if ( stristr($sql,'create table') ) |
553 | 577 | { |
@@ -574,8 +598,9 @@ discard block |
||
574 | 598 | $sql = str_replace("\n","",$sql); |
575 | 599 | $sql = "ALTER TABLE $tablename $sql"; |
576 | 600 | |
577 | - if ( $execute ) |
|
578 | - $this->query($sql,'Error with MySQL repair table'); |
|
601 | + if ( $execute ) { |
|
602 | + $this->query($sql,'Error with MySQL repair table'); |
|
603 | + } |
|
579 | 604 | |
580 | 605 | // and re-add the comments at the beginning |
581 | 606 | $sql = implode("\n",$commentBlocks) . "\n". $sql . "\n"; |
@@ -672,15 +697,18 @@ discard block |
||
672 | 697 | */ |
673 | 698 | protected function isEngineEnabled($engine) |
674 | 699 | { |
675 | - if(!is_string($engine)) return false; |
|
700 | + if(!is_string($engine)) { |
|
701 | + return false; |
|
702 | + } |
|
676 | 703 | |
677 | 704 | $engine = strtoupper($engine); |
678 | 705 | |
679 | 706 | $r = $this->query("SHOW ENGINES"); |
680 | 707 | |
681 | - while ( $row = $this->fetchByAssoc($r) ) |
|
682 | - if ( strtoupper($row['Engine']) == $engine ) |
|
708 | + while ( $row = $this->fetchByAssoc($r) ) { |
|
709 | + if ( strtoupper($row['Engine']) == $engine ) |
|
683 | 710 | return ($row['Support']=='YES' || $row['Support']=='DEFAULT'); |
711 | + } |
|
684 | 712 | |
685 | 713 | return false; |
686 | 714 | } |
@@ -708,18 +736,22 @@ discard block |
||
708 | 736 | */ |
709 | 737 | public function createTableSQLParams($tablename, $fieldDefs, $indices, $engine = null) |
710 | 738 | { |
711 | - if ( empty($engine) && isset($fieldDefs['engine'])) |
|
712 | - $engine = $fieldDefs['engine']; |
|
713 | - if ( !$this->isEngineEnabled($engine) ) |
|
714 | - $engine = ''; |
|
739 | + if ( empty($engine) && isset($fieldDefs['engine'])) { |
|
740 | + $engine = $fieldDefs['engine']; |
|
741 | + } |
|
742 | + if ( !$this->isEngineEnabled($engine) ) { |
|
743 | + $engine = ''; |
|
744 | + } |
|
715 | 745 | |
716 | 746 | $columns = $this->columnSQLRep($fieldDefs, false, $tablename); |
717 | - if (empty($columns)) |
|
718 | - return false; |
|
747 | + if (empty($columns)) { |
|
748 | + return false; |
|
749 | + } |
|
719 | 750 | |
720 | 751 | $keys = $this->keysSQL($indices); |
721 | - if (!empty($keys)) |
|
722 | - $keys = ",$keys"; |
|
752 | + if (!empty($keys)) { |
|
753 | + $keys = ",$keys"; |
|
754 | + } |
|
723 | 755 | |
724 | 756 | // cn: bug 9873 - module tables do not get created in utf8 with assoc collation |
725 | 757 | $collation = $this->getOption('collation'); |
@@ -728,8 +760,9 @@ discard block |
||
728 | 760 | } |
729 | 761 | $sql = "CREATE TABLE $tablename ($columns $keys) CHARACTER SET utf8 COLLATE $collation"; |
730 | 762 | |
731 | - if (!empty($engine)) |
|
732 | - $sql.= " ENGINE=$engine"; |
|
763 | + if (!empty($engine)) { |
|
764 | + $sql.= " ENGINE=$engine"; |
|
765 | + } |
|
733 | 766 | |
734 | 767 | return $sql; |
735 | 768 | } |
@@ -758,13 +791,15 @@ discard block |
||
758 | 791 | |
759 | 792 | // bug 22338 - don't set a default value on text or blob fields |
760 | 793 | if ( isset($ref['default']) && |
761 | - in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) |
|
762 | - $ref['default'] = ''; |
|
794 | + in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) { |
|
795 | + $ref['default'] = ''; |
|
796 | + } |
|
763 | 797 | |
764 | - if ( $return_as_array ) |
|
765 | - return $ref; |
|
766 | - else |
|
767 | - return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
798 | + if ( $return_as_array ) { |
|
799 | + return $ref; |
|
800 | + } else { |
|
801 | + return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
802 | + } |
|
768 | 803 | } |
769 | 804 | |
770 | 805 | /** |
@@ -775,16 +810,18 @@ discard block |
||
775 | 810 | $columns = array(); |
776 | 811 | if ($this->isFieldArray($fieldDefs)){ |
777 | 812 | foreach ($fieldDefs as $def){ |
778 | - if ($action == 'drop') |
|
779 | - $columns[] = $def['name']; |
|
780 | - else |
|
781 | - $columns[] = $this->oneColumnSQLRep($def, $ignoreRequired); |
|
813 | + if ($action == 'drop') { |
|
814 | + $columns[] = $def['name']; |
|
815 | + } else { |
|
816 | + $columns[] = $this->oneColumnSQLRep($def, $ignoreRequired); |
|
817 | + } |
|
782 | 818 | } |
783 | 819 | } else { |
784 | - if ($action == 'drop') |
|
785 | - $columns[] = $fieldDefs['name']; |
|
786 | - else |
|
787 | - $columns[] = $this->oneColumnSQLRep($fieldDefs); |
|
820 | + if ($action == 'drop') { |
|
821 | + $columns[] = $fieldDefs['name']; |
|
822 | + } else { |
|
823 | + $columns[] = $this->oneColumnSQLRep($fieldDefs); |
|
824 | + } |
|
788 | 825 | } |
789 | 826 | |
790 | 827 | return "ALTER TABLE $tablename $action COLUMN ".implode(",$action column ", $columns); |
@@ -806,23 +843,27 @@ discard block |
||
806 | 843 | { |
807 | 844 | // check if the passed value is an array of fields. |
808 | 845 | // if not, convert it into an array |
809 | - if (!$this->isFieldArray($indices)) |
|
810 | - $indices[] = $indices; |
|
846 | + if (!$this->isFieldArray($indices)) { |
|
847 | + $indices[] = $indices; |
|
848 | + } |
|
811 | 849 | |
812 | 850 | $columns = array(); |
813 | 851 | foreach ($indices as $index) { |
814 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
815 | - continue; |
|
816 | - if (isset($index['source']) && $index['source'] != 'db') |
|
817 | - continue; |
|
852 | + if(!empty($index['db']) && $index['db'] != $this->dbType) { |
|
853 | + continue; |
|
854 | + } |
|
855 | + if (isset($index['source']) && $index['source'] != 'db') { |
|
856 | + continue; |
|
857 | + } |
|
818 | 858 | |
819 | 859 | $type = $index['type']; |
820 | 860 | $name = $index['name']; |
821 | 861 | |
822 | - if (is_array($index['fields'])) |
|
823 | - $fields = implode(", ", $index['fields']); |
|
824 | - else |
|
825 | - $fields = $index['fields']; |
|
862 | + if (is_array($index['fields'])) { |
|
863 | + $fields = implode(", ", $index['fields']); |
|
864 | + } else { |
|
865 | + $fields = $index['fields']; |
|
866 | + } |
|
826 | 867 | |
827 | 868 | switch ($type) { |
828 | 869 | case 'unique': |
@@ -841,16 +882,18 @@ discard block |
||
841 | 882 | * that this can easily be fixed by referring to db dictionary |
842 | 883 | * to find the correct primary field name |
843 | 884 | */ |
844 | - if ( $alter_table ) |
|
845 | - $columns[] = " INDEX $name ($fields)"; |
|
846 | - else |
|
847 | - $columns[] = " KEY $name ($fields)"; |
|
885 | + if ( $alter_table ) { |
|
886 | + $columns[] = " INDEX $name ($fields)"; |
|
887 | + } else { |
|
888 | + $columns[] = " KEY $name ($fields)"; |
|
889 | + } |
|
848 | 890 | break; |
849 | 891 | case 'fulltext': |
850 | - if ($this->full_text_indexing_installed()) |
|
851 | - $columns[] = " FULLTEXT ($fields)"; |
|
852 | - else |
|
853 | - $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
892 | + if ($this->full_text_indexing_installed()) { |
|
893 | + $columns[] = " FULLTEXT ($fields)"; |
|
894 | + } else { |
|
895 | + $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
896 | + } |
|
854 | 897 | break; |
855 | 898 | } |
856 | 899 | } |
@@ -892,8 +935,9 @@ discard block |
||
892 | 935 | { |
893 | 936 | $result = $this->query("SHOW TABLE STATUS LIKE '$table'"); |
894 | 937 | $row = $this->fetchByAssoc($result); |
895 | - if (!empty($row['Auto_increment'])) |
|
896 | - return $row['Auto_increment']; |
|
938 | + if (!empty($row['Auto_increment'])) { |
|
939 | + return $row['Auto_increment']; |
|
940 | + } |
|
897 | 941 | |
898 | 942 | return ""; |
899 | 943 | } |
@@ -911,8 +955,7 @@ discard block |
||
911 | 955 | $index_type='index'; |
912 | 956 | if ($row['Key_name'] =='PRIMARY') { |
913 | 957 | $index_type='primary'; |
914 | - } |
|
915 | - elseif ( $row['Non_unique'] == '0' ) { |
|
958 | + } elseif ( $row['Non_unique'] == '0' ) { |
|
916 | 959 | $index_type='unique'; |
917 | 960 | } |
918 | 961 | $name = strtolower($row['Key_name']); |
@@ -938,29 +981,33 @@ discard block |
||
938 | 981 | case 'index': |
939 | 982 | case 'alternate_key': |
940 | 983 | case 'clustered': |
941 | - if ($drop) |
|
942 | - $sql = "ALTER TABLE {$table} DROP INDEX {$name} "; |
|
943 | - else |
|
944 | - $sql = "ALTER TABLE {$table} ADD INDEX {$name} ({$fields})"; |
|
984 | + if ($drop) { |
|
985 | + $sql = "ALTER TABLE {$table} DROP INDEX {$name} "; |
|
986 | + } else { |
|
987 | + $sql = "ALTER TABLE {$table} ADD INDEX {$name} ({$fields})"; |
|
988 | + } |
|
945 | 989 | break; |
946 | 990 | // constraints as indices |
947 | 991 | case 'unique': |
948 | - if ($drop) |
|
949 | - $sql = "ALTER TABLE {$table} DROP INDEX $name"; |
|
950 | - else |
|
951 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT UNIQUE {$name} ({$fields})"; |
|
992 | + if ($drop) { |
|
993 | + $sql = "ALTER TABLE {$table} DROP INDEX $name"; |
|
994 | + } else { |
|
995 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT UNIQUE {$name} ({$fields})"; |
|
996 | + } |
|
952 | 997 | break; |
953 | 998 | case 'primary': |
954 | - if ($drop) |
|
955 | - $sql = "ALTER TABLE {$table} DROP PRIMARY KEY"; |
|
956 | - else |
|
957 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT PRIMARY KEY ({$fields})"; |
|
999 | + if ($drop) { |
|
1000 | + $sql = "ALTER TABLE {$table} DROP PRIMARY KEY"; |
|
1001 | + } else { |
|
1002 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT PRIMARY KEY ({$fields})"; |
|
1003 | + } |
|
958 | 1004 | break; |
959 | 1005 | case 'foreign': |
960 | - if ($drop) |
|
961 | - $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
962 | - else |
|
963 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT FOREIGN KEY {$name} ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignField']})"; |
|
1006 | + if ($drop) { |
|
1007 | + $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
1008 | + } else { |
|
1009 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT FOREIGN KEY {$name} ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignField']})"; |
|
1010 | + } |
|
964 | 1011 | break; |
965 | 1012 | } |
966 | 1013 | return $sql; |
@@ -1003,22 +1050,30 @@ discard block |
||
1003 | 1050 | ($fieldDef['dbType'] == 'text' |
1004 | 1051 | || $fieldDef['dbType'] == 'blob' |
1005 | 1052 | || $fieldDef['dbType'] == 'longtext' |
1006 | - || $fieldDef['dbType'] == 'longblob' )) |
|
1007 | - unset($fieldDef['default']); |
|
1008 | - if ($fieldDef['dbType'] == 'uint') |
|
1009 | - $fieldDef['len'] = '10'; |
|
1010 | - if ($fieldDef['dbType'] == 'ulong') |
|
1011 | - $fieldDef['len'] = '20'; |
|
1012 | - if ($fieldDef['dbType'] == 'bool') |
|
1013 | - $fieldDef['type'] = 'tinyint'; |
|
1014 | - if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) |
|
1015 | - $fieldDef['default'] = '0'; |
|
1016 | - if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) |
|
1017 | - $fieldDef['len'] = '255'; |
|
1018 | - if ($fieldDef['dbType'] == 'uint') |
|
1019 | - $fieldDef['len'] = '10'; |
|
1020 | - if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) |
|
1021 | - $fieldDef['len'] = '11'; |
|
1053 | + || $fieldDef['dbType'] == 'longblob' )) { |
|
1054 | + unset($fieldDef['default']); |
|
1055 | + } |
|
1056 | + if ($fieldDef['dbType'] == 'uint') { |
|
1057 | + $fieldDef['len'] = '10'; |
|
1058 | + } |
|
1059 | + if ($fieldDef['dbType'] == 'ulong') { |
|
1060 | + $fieldDef['len'] = '20'; |
|
1061 | + } |
|
1062 | + if ($fieldDef['dbType'] == 'bool') { |
|
1063 | + $fieldDef['type'] = 'tinyint'; |
|
1064 | + } |
|
1065 | + if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) { |
|
1066 | + $fieldDef['default'] = '0'; |
|
1067 | + } |
|
1068 | + if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) { |
|
1069 | + $fieldDef['len'] = '255'; |
|
1070 | + } |
|
1071 | + if ($fieldDef['dbType'] == 'uint') { |
|
1072 | + $fieldDef['len'] = '10'; |
|
1073 | + } |
|
1074 | + if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) { |
|
1075 | + $fieldDef['len'] = '11'; |
|
1076 | + } |
|
1022 | 1077 | |
1023 | 1078 | if($fieldDef['dbType'] == 'decimal') { |
1024 | 1079 | if(isset($fieldDef['len'])) { |
@@ -1058,8 +1113,9 @@ discard block |
||
1058 | 1113 | } |
1059 | 1114 | if (!empty($sql)) { |
1060 | 1115 | $sql = "ALTER TABLE $tablename " . join(",", $sql) . ";"; |
1061 | - if($execute) |
|
1062 | - $this->query($sql); |
|
1116 | + if($execute) { |
|
1117 | + $this->query($sql); |
|
1118 | + } |
|
1063 | 1119 | } else { |
1064 | 1120 | $sql = ''; |
1065 | 1121 | } |