| @@ 835-852 (lines=18) @@ | ||
| 832 | $data = 'INSERT INTO `' . $tableName . '`' . $crlf . "\t" . '(`' . implode('`, `', $fields) . '`)' . $crlf . 'VALUES '; |
|
| 833 | ||
| 834 | // Loop through each row. |
|
| 835 | while ($row = $this->fetch_assoc($result)) |
|
| 836 | { |
|
| 837 | // Get the fields in this row... |
|
| 838 | $field_list = array(); |
|
| 839 | ||
| 840 | foreach ($row as $key => $item) |
|
| 841 | { |
|
| 842 | // Try to figure out the type of each field. (NULL, number, or 'string'.) |
|
| 843 | if (!isset($item)) |
|
| 844 | $field_list[] = 'NULL'; |
|
| 845 | elseif (is_numeric($item) && (int) $item == $item) |
|
| 846 | $field_list[] = $item; |
|
| 847 | else |
|
| 848 | $field_list[] = '\'' . $this->escape_string($item) . '\''; |
|
| 849 | } |
|
| 850 | ||
| 851 | $data .= '(' . implode(', ', $field_list) . '),' . $crlf . "\t"; |
|
| 852 | } |
|
| 853 | ||
| 854 | $this->free_result($result); |
|
| 855 | $data = substr(trim($data), 0, -1) . ';' . $crlf . $crlf; |
|
| @@ 734-752 (lines=19) @@ | ||
| 731 | $insert_msg = 'INSERT INTO ' . $tableName . $crlf . "\t" . '(' . implode(', ', $fields) . ')' . $crlf . 'VALUES ' . $crlf . "\t"; |
|
| 732 | ||
| 733 | // Loop through each row. |
|
| 734 | while ($row = $this->fetch_assoc($result)) |
|
| 735 | { |
|
| 736 | // Get the fields in this row... |
|
| 737 | $field_list = array(); |
|
| 738 | ||
| 739 | foreach ($row as $key => $item) |
|
| 740 | { |
|
| 741 | // Try to figure out the type of each field. (NULL, number, or 'string'.) |
|
| 742 | if (!isset($item)) |
|
| 743 | $field_list[] = 'NULL'; |
|
| 744 | elseif (is_numeric($item) && (int) $item == $item) |
|
| 745 | $field_list[] = $item; |
|
| 746 | else |
|
| 747 | $field_list[] = '\'' . $this->escape_string($item) . '\''; |
|
| 748 | } |
|
| 749 | ||
| 750 | // 'Insert' the data. |
|
| 751 | $data .= $insert_msg . '(' . implode(', ', $field_list) . ');' . $crlf; |
|
| 752 | } |
|
| 753 | $this->free_result($result); |
|
| 754 | ||
| 755 | $data .= $crlf; |
|