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