| @@ 558-575 (lines=18) @@ | ||
| 555 | ||
| 556 | // Get a list of text columns. |
|
| 557 | $columns = array(); |
|
| 558 | if ($db_type == 'postgresql') |
|
| 559 | $request = $smcFunc['db_query']('', ' |
|
| 560 | SELECT column_name "Field", data_type "Type" |
|
| 561 | FROM information_schema.columns |
|
| 562 | WHERE table_name = {string:cur_table} |
|
| 563 | AND (data_type = \'character varying\' or data_type = \'text\')', |
|
| 564 | array( |
|
| 565 | 'cur_table' => $db_prefix.$cur_table, |
|
| 566 | ) |
|
| 567 | ); |
|
| 568 | else |
|
| 569 | $request = $smcFunc['db_query']('', ' |
|
| 570 | SHOW FULL COLUMNS |
|
| 571 | FROM {db_prefix}{raw:cur_table}', |
|
| 572 | array( |
|
| 573 | 'cur_table' => $cur_table, |
|
| 574 | ) |
|
| 575 | ); |
|
| 576 | while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
| 577 | if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 578 | $columns[] = strtolower($column_info['Field']); |
|
| @@ 581-600 (lines=20) @@ | ||
| 578 | $columns[] = strtolower($column_info['Field']); |
|
| 579 | ||
| 580 | // Get the column with the (first) primary key. |
|
| 581 | if ($db_type == 'postgresql') |
|
| 582 | $request = $smcFunc['db_query']('', ' |
|
| 583 | SELECT a.attname "Column_name", \'PRIMARY\' "Key_name", attnum "Seq_in_index" |
|
| 584 | FROM pg_index i |
|
| 585 | JOIN pg_attribute a ON a.attrelid = i.indrelid |
|
| 586 | AND a.attnum = ANY(i.indkey) |
|
| 587 | WHERE i.indrelid = {string:cur_table}::regclass |
|
| 588 | AND i.indisprimary', |
|
| 589 | array( |
|
| 590 | 'cur_table' => $db_prefix.$cur_table, |
|
| 591 | ) |
|
| 592 | ); |
|
| 593 | else |
|
| 594 | $request = $smcFunc['db_query']('', ' |
|
| 595 | SHOW KEYS |
|
| 596 | FROM {db_prefix}{raw:cur_table}', |
|
| 597 | array( |
|
| 598 | 'cur_table' => $cur_table, |
|
| 599 | ) |
|
| 600 | ); |
|
| 601 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 602 | { |
|
| 603 | if ($row['Key_name'] === 'PRIMARY') |
|