@@ -382,7 +382,7 @@ |
||
| 382 | 382 | * @param array $parameters Not used? |
| 383 | 383 | * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated. |
| 384 | 384 | * @param string $error |
| 385 | - * @return boolean Whether or not the operation was successful |
|
| 385 | + * @return false|null Whether or not the operation was successful |
|
| 386 | 386 | */ |
| 387 | 387 | function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal') |
| 388 | 388 | { |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | $smcFunc['db_drop_table']($table_name); |
| 123 | 123 | else if ($if_exists == 'update') |
| 124 | 124 | { |
| 125 | - $smcFunc['db_drop_table']($table_name.'_old'); |
|
| 125 | + $smcFunc['db_drop_table']($table_name . '_old'); |
|
| 126 | 126 | $smcFunc['db_transaction']('begin'); |
| 127 | 127 | $db_trans = true; |
| 128 | - $smcFunc['db_query']('',' |
|
| 129 | - ALTER TABLE '. $table_name .' RENAME TO ' . $table_name . '_old', |
|
| 128 | + $smcFunc['db_query']('', ' |
|
| 129 | + ALTER TABLE '. $table_name . ' RENAME TO ' . $table_name . '_old', |
|
| 130 | 130 | array( |
| 131 | 131 | 'security_override' => true, |
| 132 | 132 | ) |
@@ -213,15 +213,15 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | $same_col = array(); |
| 215 | 215 | |
| 216 | - $request = $smcFunc['db_query']('',' |
|
| 216 | + $request = $smcFunc['db_query']('', ' |
|
| 217 | 217 | SELECT count(*), column_name |
| 218 | 218 | FROM information_schema.columns |
| 219 | 219 | WHERE table_name in ({string:table1},{string:table2}) AND table_schema = {string:schema} |
| 220 | 220 | GROUP BY column_name |
| 221 | 221 | HAVING count(*) > 1', |
| 222 | - array ( |
|
| 222 | + array( |
|
| 223 | 223 | 'table1' => $table_name, |
| 224 | - 'table2' => $table_name.'_old', |
|
| 224 | + 'table2' => $table_name . '_old', |
|
| 225 | 225 | 'schema' => 'public', |
| 226 | 226 | ) |
| 227 | 227 | ); |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | $same_col[] = $row['column_name']; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $smcFunc['db_query']('',' |
|
| 235 | - INSERT INTO ' . $table_name .'(' |
|
| 234 | + $smcFunc['db_query']('', ' |
|
| 235 | + INSERT INTO ' . $table_name . '(' |
|
| 236 | 236 | . implode($same_col, ',') . |
| 237 | 237 | ') |
| 238 | 238 | SELECT '. implode($same_col, ',') . ' |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -53,8 +54,9 @@ discard block |
||
| 53 | 54 | 'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
| 54 | 55 | 'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
| 55 | 56 | 'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes'); |
| 56 | - foreach ($reservedTables as $k => $table_name) |
|
| 57 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 57 | + foreach ($reservedTables as $k => $table_name) { |
|
| 58 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 59 | + } |
|
| 58 | 60 | |
| 59 | 61 | // We in turn may need the extra stuff. |
| 60 | 62 | db_extend('extra'); |
@@ -107,8 +109,9 @@ discard block |
||
| 107 | 109 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 108 | 110 | |
| 109 | 111 | // First - no way do we touch SMF tables. |
| 110 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 111 | - return false; |
|
| 112 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 113 | + return false; |
|
| 114 | + } |
|
| 112 | 115 | |
| 113 | 116 | // Log that we'll want to remove this on uninstall. |
| 114 | 117 | $db_package_log[] = array('remove_table', $table_name); |
@@ -118,9 +121,9 @@ discard block |
||
| 118 | 121 | if (in_array($full_table_name, $tables)) |
| 119 | 122 | { |
| 120 | 123 | // This is a sad day... drop the table? If not, return false (error) by default. |
| 121 | - if ($if_exists == 'overwrite') |
|
| 122 | - $smcFunc['db_drop_table']($table_name); |
|
| 123 | - else if ($if_exists == 'update') |
|
| 124 | + if ($if_exists == 'overwrite') { |
|
| 125 | + $smcFunc['db_drop_table']($table_name); |
|
| 126 | + } else if ($if_exists == 'update') |
|
| 124 | 127 | { |
| 125 | 128 | $smcFunc['db_drop_table']($table_name.'_old'); |
| 126 | 129 | $smcFunc['db_transaction']('begin'); |
@@ -132,47 +135,51 @@ discard block |
||
| 132 | 135 | ) |
| 133 | 136 | ); |
| 134 | 137 | $old_table_exists = true; |
| 138 | + } else { |
|
| 139 | + return $if_exists == 'ignore'; |
|
| 135 | 140 | } |
| 136 | - else |
|
| 137 | - return $if_exists == 'ignore'; |
|
| 138 | 141 | } |
| 139 | 142 | |
| 140 | 143 | // If we've got this far - good news - no table exists. We can build our own! |
| 141 | - if (!$db_trans) |
|
| 142 | - $smcFunc['db_transaction']('begin'); |
|
| 144 | + if (!$db_trans) { |
|
| 145 | + $smcFunc['db_transaction']('begin'); |
|
| 146 | + } |
|
| 143 | 147 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
| 144 | 148 | foreach ($columns as $column) |
| 145 | 149 | { |
| 146 | 150 | // If we have an auto increment do it! |
| 147 | 151 | if (!empty($column['auto'])) |
| 148 | 152 | { |
| 149 | - if (!$old_table_exists) |
|
| 150 | - $smcFunc['db_query']('', ' |
|
| 153 | + if (!$old_table_exists) { |
|
| 154 | + $smcFunc['db_query']('', ' |
|
| 151 | 155 | DROP SEQUENCE IF EXISTS ' . $table_name . '_seq', |
| 152 | 156 | array( |
| 153 | 157 | 'security_override' => true, |
| 154 | 158 | ) |
| 155 | 159 | ); |
| 160 | + } |
|
| 156 | 161 | |
| 157 | - if (!$old_table_exists) |
|
| 158 | - $smcFunc['db_query']('', ' |
|
| 162 | + if (!$old_table_exists) { |
|
| 163 | + $smcFunc['db_query']('', ' |
|
| 159 | 164 | CREATE SEQUENCE ' . $table_name . '_seq', |
| 160 | 165 | array( |
| 161 | 166 | 'security_override' => true, |
| 162 | 167 | ) |
| 163 | 168 | ); |
| 169 | + } |
|
| 164 | 170 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
| 171 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
| 172 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 173 | + } else { |
|
| 174 | + $default = ''; |
|
| 165 | 175 | } |
| 166 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
| 167 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 168 | - else |
|
| 169 | - $default = ''; |
|
| 170 | 176 | |
| 171 | 177 | // Sort out the size... |
| 172 | 178 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
| 173 | 179 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
| 174 | - if ($size !== null) |
|
| 175 | - $type = $type . '(' . $size . ')'; |
|
| 180 | + if ($size !== null) { |
|
| 181 | + $type = $type . '(' . $size . ')'; |
|
| 182 | + } |
|
| 176 | 183 | |
| 177 | 184 | // Now just put it together! |
| 178 | 185 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -185,19 +192,21 @@ discard block |
||
| 185 | 192 | $columns = implode(',', $index['columns']); |
| 186 | 193 | |
| 187 | 194 | // Primary goes in the table... |
| 188 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
| 189 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 190 | - else |
|
| 195 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
| 196 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 197 | + } else |
|
| 191 | 198 | { |
| 192 | - if (empty($index['name'])) |
|
| 193 | - $index['name'] = implode('_', $index['columns']); |
|
| 199 | + if (empty($index['name'])) { |
|
| 200 | + $index['name'] = implode('_', $index['columns']); |
|
| 201 | + } |
|
| 194 | 202 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
| 195 | 203 | } |
| 196 | 204 | } |
| 197 | 205 | |
| 198 | 206 | // No trailing commas! |
| 199 | - if (substr($table_query, -1) == ',') |
|
| 200 | - $table_query = substr($table_query, 0, -1); |
|
| 207 | + if (substr($table_query, -1) == ',') { |
|
| 208 | + $table_query = substr($table_query, 0, -1); |
|
| 209 | + } |
|
| 201 | 210 | |
| 202 | 211 | $table_query .= ')'; |
| 203 | 212 | |
@@ -242,18 +251,20 @@ discard block |
||
| 242 | 251 | } |
| 243 | 252 | |
| 244 | 253 | // And the indexes... |
| 245 | - foreach ($index_queries as $query) |
|
| 246 | - $smcFunc['db_query']('', $query, |
|
| 254 | + foreach ($index_queries as $query) { |
|
| 255 | + $smcFunc['db_query']('', $query, |
|
| 247 | 256 | array( |
| 248 | 257 | 'security_override' => true, |
| 249 | 258 | ) |
| 250 | 259 | ); |
| 260 | + } |
|
| 251 | 261 | |
| 252 | 262 | // Go, go power rangers! |
| 253 | 263 | $smcFunc['db_transaction']('commit'); |
| 254 | 264 | |
| 255 | - if ($old_table_exists) |
|
| 256 | - $smcFunc['db_drop_table']($table_name . '_old'); |
|
| 265 | + if ($old_table_exists) { |
|
| 266 | + $smcFunc['db_drop_table']($table_name . '_old'); |
|
| 267 | + } |
|
| 257 | 268 | |
| 258 | 269 | return true; |
| 259 | 270 | } |
@@ -278,8 +289,9 @@ discard block |
||
| 278 | 289 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 279 | 290 | |
| 280 | 291 | // God no - dropping one of these = bad. |
| 281 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 282 | - return false; |
|
| 292 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 293 | + return false; |
|
| 294 | + } |
|
| 283 | 295 | |
| 284 | 296 | // Does it exist? |
| 285 | 297 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -337,21 +349,24 @@ discard block |
||
| 337 | 349 | |
| 338 | 350 | // Does it exist - if so don't add it again! |
| 339 | 351 | $columns = $smcFunc['db_list_columns']($table_name, false); |
| 340 | - foreach ($columns as $column) |
|
| 341 | - if ($column == $column_info['name']) |
|
| 352 | + foreach ($columns as $column) { |
|
| 353 | + if ($column == $column_info['name']) |
|
| 342 | 354 | { |
| 343 | 355 | // If we're going to overwrite then use change column. |
| 344 | 356 | if ($if_exists == 'update') |
| 345 | 357 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
| 346 | - else |
|
| 347 | - return false; |
|
| 358 | + } |
|
| 359 | + else { |
|
| 360 | + return false; |
|
| 361 | + } |
|
| 348 | 362 | } |
| 349 | 363 | |
| 350 | 364 | // Get the specifics... |
| 351 | 365 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
| 352 | 366 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
| 353 | - if ($size !== null) |
|
| 354 | - $type = $type . '(' . $size . ')'; |
|
| 367 | + if ($size !== null) { |
|
| 368 | + $type = $type . '(' . $size . ')'; |
|
| 369 | + } |
|
| 355 | 370 | |
| 356 | 371 | // Now add the thing! |
| 357 | 372 | $query = ' |
@@ -366,11 +381,12 @@ discard block |
||
| 366 | 381 | // If there's more attributes they need to be done via a change on PostgreSQL. |
| 367 | 382 | unset($column_info['type'], $column_info['size']); |
| 368 | 383 | |
| 369 | - if (count($column_info) != 1) |
|
| 370 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
| 371 | - else |
|
| 372 | - return true; |
|
| 373 | -} |
|
| 384 | + if (count($column_info) != 1) { |
|
| 385 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
| 386 | + } else { |
|
| 387 | + return true; |
|
| 388 | + } |
|
| 389 | + } |
|
| 374 | 390 | |
| 375 | 391 | /** |
| 376 | 392 | * Removes a column. |
@@ -389,8 +405,8 @@ discard block |
||
| 389 | 405 | |
| 390 | 406 | // Does it exist? |
| 391 | 407 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 392 | - foreach ($columns as $column) |
|
| 393 | - if ($column['name'] == $column_name) |
|
| 408 | + foreach ($columns as $column) { |
|
| 409 | + if ($column['name'] == $column_name) |
|
| 394 | 410 | { |
| 395 | 411 | // If there is an auto we need remove it! |
| 396 | 412 | if ($column['auto']) |
@@ -400,6 +416,7 @@ discard block |
||
| 400 | 416 | 'security_override' => true, |
| 401 | 417 | ) |
| 402 | 418 | ); |
| 419 | + } |
|
| 403 | 420 | |
| 404 | 421 | $smcFunc['db_query']('', ' |
| 405 | 422 | ALTER TABLE ' . $table_name . ' |
@@ -433,13 +450,15 @@ discard block |
||
| 433 | 450 | // Check it does exist! |
| 434 | 451 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 435 | 452 | $old_info = null; |
| 436 | - foreach ($columns as $column) |
|
| 437 | - if ($column['name'] == $old_column) |
|
| 453 | + foreach ($columns as $column) { |
|
| 454 | + if ($column['name'] == $old_column) |
|
| 438 | 455 | $old_info = $column; |
| 456 | + } |
|
| 439 | 457 | |
| 440 | 458 | // Nothing? |
| 441 | - if ($old_info == null) |
|
| 442 | - return false; |
|
| 459 | + if ($old_info == null) { |
|
| 460 | + return false; |
|
| 461 | + } |
|
| 443 | 462 | |
| 444 | 463 | // Now we check each bit individually and ALTER as required. |
| 445 | 464 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -496,8 +515,9 @@ discard block |
||
| 496 | 515 | { |
| 497 | 516 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
| 498 | 517 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
| 499 | - if ($size !== null) |
|
| 500 | - $type = $type . '(' . $size . ')'; |
|
| 518 | + if ($size !== null) { |
|
| 519 | + $type = $type . '(' . $size . ')'; |
|
| 520 | + } |
|
| 501 | 521 | |
| 502 | 522 | // The alter is a pain. |
| 503 | 523 | $smcFunc['db_transaction']('begin'); |
@@ -598,21 +618,23 @@ discard block |
||
| 598 | 618 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 599 | 619 | |
| 600 | 620 | // No columns = no index. |
| 601 | - if (empty($index_info['columns'])) |
|
| 602 | - return false; |
|
| 621 | + if (empty($index_info['columns'])) { |
|
| 622 | + return false; |
|
| 623 | + } |
|
| 603 | 624 | $columns = implode(',', $index_info['columns']); |
| 604 | 625 | |
| 605 | 626 | // No name - make it up! |
| 606 | 627 | if (empty($index_info['name'])) |
| 607 | 628 | { |
| 608 | 629 | // No need for primary. |
| 609 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
| 610 | - $index_info['name'] = ''; |
|
| 611 | - else |
|
| 612 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
| 630 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
| 631 | + $index_info['name'] = ''; |
|
| 632 | + } else { |
|
| 633 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
| 634 | + } |
|
| 635 | + } else { |
|
| 636 | + $index_info['name'] = $table_name . $index_info['name']; |
|
| 613 | 637 | } |
| 614 | - else |
|
| 615 | - $index_info['name'] = $table_name . $index_info['name']; |
|
| 616 | 638 | |
| 617 | 639 | // Log that we are going to want to remove this! |
| 618 | 640 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -625,10 +647,11 @@ discard block |
||
| 625 | 647 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
| 626 | 648 | { |
| 627 | 649 | // If we want to overwrite simply remove the current one then continue. |
| 628 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
| 629 | - return false; |
|
| 630 | - else |
|
| 631 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 650 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
| 651 | + return false; |
|
| 652 | + } else { |
|
| 653 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 654 | + } |
|
| 632 | 655 | } |
| 633 | 656 | } |
| 634 | 657 | |
@@ -642,8 +665,7 @@ discard block |
||
| 642 | 665 | 'security_override' => true, |
| 643 | 666 | ) |
| 644 | 667 | ); |
| 645 | - } |
|
| 646 | - else |
|
| 668 | + } else |
|
| 647 | 669 | { |
| 648 | 670 | $smcFunc['db_query']('', ' |
| 649 | 671 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -671,8 +693,9 @@ discard block |
||
| 671 | 693 | |
| 672 | 694 | // Better exist! |
| 673 | 695 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
| 674 | - if ($index_name != 'primary') |
|
| 675 | - $index_name = $table_name . '_' . $index_name; |
|
| 696 | + if ($index_name != 'primary') { |
|
| 697 | + $index_name = $table_name . '_' . $index_name; |
|
| 698 | + } |
|
| 676 | 699 | |
| 677 | 700 | foreach ($indexes as $index) |
| 678 | 701 | { |
@@ -736,8 +759,7 @@ discard block |
||
| 736 | 759 | 'datetime' => 'timestamp without time zone', |
| 737 | 760 | 'timestamp' => 'timestamp without time zone', |
| 738 | 761 | ); |
| 739 | - } |
|
| 740 | - else |
|
| 762 | + } else |
|
| 741 | 763 | { |
| 742 | 764 | $types = array( |
| 743 | 765 | 'character varying' => 'varchar', |
@@ -753,14 +775,16 @@ discard block |
||
| 753 | 775 | // Got it? Change it! |
| 754 | 776 | if (isset($types[$type_name])) |
| 755 | 777 | { |
| 756 | - if ($type_name == 'tinytext') |
|
| 757 | - $type_size = 255; |
|
| 778 | + if ($type_name == 'tinytext') { |
|
| 779 | + $type_size = 255; |
|
| 780 | + } |
|
| 758 | 781 | $type_name = $types[$type_name]; |
| 759 | 782 | } |
| 760 | 783 | |
| 761 | 784 | // Only char fields got size |
| 762 | - if (strpos($type_name, 'char') === false) |
|
| 763 | - $type_size = null; |
|
| 785 | + if (strpos($type_name, 'char') === false) { |
|
| 786 | + $type_size = null; |
|
| 787 | + } |
|
| 764 | 788 | |
| 765 | 789 | |
| 766 | 790 | return array($type_name, $type_size); |
@@ -816,8 +840,7 @@ discard block |
||
| 816 | 840 | if (!$detail) |
| 817 | 841 | { |
| 818 | 842 | $columns[] = $row['column_name']; |
| 819 | - } |
|
| 820 | - else |
|
| 843 | + } else |
|
| 821 | 844 | { |
| 822 | 845 | $auto = false; |
| 823 | 846 | // What is the default? |
@@ -825,11 +848,11 @@ discard block |
||
| 825 | 848 | { |
| 826 | 849 | $default = null; |
| 827 | 850 | $auto = true; |
| 851 | + } elseif (trim($row['column_default']) != '') { |
|
| 852 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
| 853 | + } else { |
|
| 854 | + $default = null; |
|
| 828 | 855 | } |
| 829 | - elseif (trim($row['column_default']) != '') |
|
| 830 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
| 831 | - else |
|
| 832 | - $default = null; |
|
| 833 | 856 | |
| 834 | 857 | // Make the type generic. |
| 835 | 858 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -880,26 +903,30 @@ discard block |
||
| 880 | 903 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 881 | 904 | { |
| 882 | 905 | // Try get the columns that make it up. |
| 883 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
| 884 | - continue; |
|
| 906 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
| 907 | + continue; |
|
| 908 | + } |
|
| 885 | 909 | |
| 886 | 910 | $columns = explode(',', $matches[1]); |
| 887 | 911 | |
| 888 | - if (empty($columns)) |
|
| 889 | - continue; |
|
| 912 | + if (empty($columns)) { |
|
| 913 | + continue; |
|
| 914 | + } |
|
| 890 | 915 | |
| 891 | - foreach ($columns as $k => $v) |
|
| 892 | - $columns[$k] = trim($v); |
|
| 916 | + foreach ($columns as $k => $v) { |
|
| 917 | + $columns[$k] = trim($v); |
|
| 918 | + } |
|
| 893 | 919 | |
| 894 | 920 | // Fix up the name to be consistent cross databases |
| 895 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
| 896 | - $row['name'] = 'PRIMARY'; |
|
| 897 | - else |
|
| 898 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
| 921 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
| 922 | + $row['name'] = 'PRIMARY'; |
|
| 923 | + } else { |
|
| 924 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
| 925 | + } |
|
| 899 | 926 | |
| 900 | - if (!$detail) |
|
| 901 | - $indexes[] = $row['name']; |
|
| 902 | - else |
|
| 927 | + if (!$detail) { |
|
| 928 | + $indexes[] = $row['name']; |
|
| 929 | + } else |
|
| 903 | 930 | { |
| 904 | 931 | $indexes[$row['name']] = array( |
| 905 | 932 | 'name' => $row['name'], |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |