/**
* Does an import to a particular table from a text file
*
- * $Id: dataimport.php,v 1.9 2005/10/05 13:05:32 chriskl Exp $
+ * $Id: dataimport.php,v 1.10 2005/10/09 09:05:16 chriskl Exp $
*/
// Prevent timeouts on large exports (non-safe mode only)
}
}
- function LoadNULLArray(&$Array) {
- $Success = true;
- $AllowedNulls = $_POST['AllowedNulls'];
- if (!is_null($AllowedNulls)) {
- $Array = array();
- foreach($AllowedNulls as $NullChar) {
- if ($NullChar == 'Default') {
- $Array[2] = "\\N";
- } else if ($NullChar == 'NULL') {
- $Array[0] = "NULL";
- } else if ($NullChar == 'EmptyString') {
- $Array[1] = null;
- } else {
- $misc->printMsg(sprintf($lang['strimporter-badnull'], $NullChar));
- exit;
+ function loadNULLArray() {
+ $array = array();
+ if (isset($_POST['allowednulls'])) {
+ foreach($_POST['allowednulls'] as $null_char) {
+ switch ($null_char) {
+ case 'default':
+ $array[] = "\\N";
+ break;
+ case 'null':
+ $array[] = "NULL";
+ break;
+ case 'emptystring':
+ $array[] = null;
+ break;
}
}
}
+ return $array;
}
- function DetermineNull($field, $NullArray) {
- $FoundANull = false;
- while((list($Ignored, $Nulls) = each($NullArray)) && ($FoundANull == false)) {
- if ($Nulls == $field) {
- $FoundANull = true;
- }
- }
- reset($NullArray);
- return $FoundANull;
+ function determineNull($field, $null_array) {
+ return in_array($field, $null_array);
}
-
$misc->printHeader($lang['strimport']);
$misc->printTrail('table');
$misc->printTabs('table','import');
$fd = fopen($_FILES['source']['tmp_name'], 'r');
// Check that file was opened successfully
if ($fd !== false) {
- $NullArray = null;
- LoadNULLArray($NullArray);
+ $null_array = loadNULLArray();
$status = $data->beginTransaction();
if ($status != 0) {
- $misc->printMsg($lang['strimporterror-badtransaction']);
+ $misc->printMsg($lang['strimporterror']);
exit;
}
exit;
}
// Check for nulls
- if (DetermineNull($line[$i], $NullArray)) {
+ if (determineNull($line[$i], $null_array)) {
$nulls[$f] = 'on';
}
// Add to value array
$types[$f] = 'text';
$i++;
}
+
$status = $data->insertRow($_REQUEST['table'], $vars, $nulls, $format, $types);
if ($status != 0) {
$data->rollbackTransaction();
- $misc->printMsg(sprintf($lang['strimporterrorline-dberror'], $row));
+ $misc->printMsg(sprintf($lang['strimporterrorline'], $row));
exit;
}
$row++;
$status = $data->endTransaction();
if ($status != 0) {
- $misc->printMsg($lang['strimporterror-badtransaction']);
+ $misc->printMsg($lang['strimporterror']);
exit;
}
fclose($fd);
}
else {
// File could not be opened
- $misc->printMsg($lang['strimporterror-unopenedfile']);
+ $misc->printMsg($lang['strimporterror']);
}
}
else {
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.182 2005/10/05 13:05:32 chriskl Exp $
+ * $Id: english.php,v 1.183 2005/10/09 09:05:16 chriskl Exp $
*/
// Language and character set
$lang['strprimary'] = 'Primary';
$lang['strexport'] = 'Export';
$lang['strimport'] = 'Import';
- $lang['strAllowedNulls'] = 'Allowed Null Characters';
- $lang['strNULL'] = 'NULL (The word)';
- $lang['strEmptyString'] = 'Empty String/Field';
- $lang['strBackslashN'] = '\N (Export Default)';
+ $lang['strallowednulls'] = 'Allowed NULL Characters';
+ $lang['strbackslashn'] = '\N';
+ $lang['strnull'] = 'NULL (The word)';
+ $lang['stremptystring'] = 'Empty string/field';
$lang['strsql'] = 'SQL';
$lang['stradmin'] = 'Admin';
$lang['strvacuum'] = 'Vacuum';
$lang['strnoreportsdb'] = 'You have not created the reports database. Read the INSTALL file for directions.';
$lang['strnouploads'] = 'File uploads are disabled.';
$lang['strimporterror'] = 'Import error.';
- $lang['strimporter-badnull'] = 'The NULL character you have supplied [%s], has not been configured for use yet.';
- $lang['strimporterror-badtransaction'] = 'Import error (There was a problem starting/ending the transaction).';
- $lang['strimporterror-fileformat'] = 'Import error (Failed to determine which file format was given).';
+ $lang['strimporterror-fileformat'] = 'Import error: Failed to automatically determine the file format.';
$lang['strimporterrorline'] = 'Import error on line %s.';
- $lang['strimporterrorline-badcolumnnum'] = 'Import error on line %s. (This line does not possess the correct number of columns)';
- $lang['strimporterrorline-dberror'] = 'Import error on line %s. (This line could not be inserted into the database)';
- $lang['strimporterror-unopenedfile'] = 'Import error (Uploaded file could not be opened by the import engine)';
- $lang['strimporterror-uploadedfile'] = 'Import error: (File could not be uploaded to the server)';
+ $lang['strimporterrorline-badcolumnnum'] = 'Import error on line %s: Line does not possess the correct number of columns.';
+ $lang['strimporterror-uploadedfile'] = 'Import error: File could not be uploaded to the server';
$lang['strcannotdumponwindows'] = 'Dumping of complex table and schema names on Windows is not supported.';
// Tables
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.134 2005/10/05 13:05:32 chriskl Exp $
+ * $Id: english.php,v 1.135 2005/10/09 09:05:16 chriskl Exp $
*/
// Language and character set
$lang['strprimary'] = 'Primary';
$lang['strexport'] = 'Export';
$lang['strimport'] = 'Import';
- $lang['strAllowedNulls'] = 'Allowed Null Characters';
- $lang['strNULL'] = 'NULL (The word)';
- $lang['strEmptyString'] = 'Empty String/Field';
- $lang['strBackslashN'] = '\N (Export Default)';
+ $lang['strallowednulls'] = 'Allowed NULL Characters';
+ $lang['strbackslashn'] = '\N';
+ $lang['strnull'] = 'NULL (The word)';
+ $lang['stremptystring'] = 'Empty string/field';
$lang['strsql'] = 'SQL';
$lang['stradmin'] = 'Admin';
$lang['strvacuum'] = 'Vacuum';
$lang['strnoreportsdb'] = 'You have not created the reports database. Read the INSTALL file for directions.';
$lang['strnouploads'] = 'File uploads are disabled.';
$lang['strimporterror'] = 'Import error.';
- $lang['strimporter-badnull'] = 'The NULL character you have supplied [%s], has not been configured for use yet.';
- $lang['strimporterror-badtransaction'] = 'Import error (There was a problem starting/ending the transaction).';
- $lang['strimporterror-fileformat'] = 'Import error (Failed to determine which file format was given).';
+ $lang['strimporterror-fileformat'] = 'Import error: Failed to automatically determine the file format.';
$lang['strimporterrorline'] = 'Import error on line %s.';
- $lang['strimporterrorline-badcolumnnum'] = 'Import error on line %s. (This line does not possess the correct number of columns)';
- $lang['strimporterrorline-dberror'] = 'Import error on line %s. (This line could not be inserted into the database)';
- $lang['strimporterror-unopenedfile'] = 'Import error (Uploaded file could not be opened by the import engine)';
- $lang['strimporterror-uploadedfile'] = 'Import error: (File could not be uploaded to the server)';
+ $lang['strimporterrorline-badcolumnnum'] = 'Import error on line %s: Line does not possess the correct number of columns.';
+ $lang['strimporterror-uploadedfile'] = 'Import error: File could not be uploaded to the server';
$lang['strcannotdumponwindows'] = 'Dumping of complex table and schema names on Windows is not supported.';
// Tables
/**
* List tables in a database
*
- * $Id: tblproperties.php,v 1.64 2005/10/05 13:05:32 chriskl Exp $
+ * $Id: tblproperties.php,v 1.65 2005/10/09 09:05:16 chriskl Exp $
*/
// Include application functions
echo "<option value=\"xml\">XML</option>\n";
}
echo "</select>\n</td>\n</tr>\n";
- echo "<tr><th class=\"data left required\">{$lang['strAllowedNulls']}</th>";
- echo "<td><select multiple size=\"3\" name=\"AllowedNulls[]\">\n";
- echo "<option value=\"Default\">{$lang['strBackslashN']}</option>\n";
- echo "<option value=\"NULL\">{$lang['strNULL']}</option>\n";
- echo "<option value=\"EmptyString\">{$lang['strEmptyString'] }</option>\n";
+ echo "<tr><th class=\"data left required\">{$lang['strallowednulls']}</th>";
+ echo "<td><select multiple size=\"3\" name=\"allowednulls[]\">\n";
+ echo "<option value=\"default\" selected=\"selected\">{$lang['strbackslashn']}</option>\n";
+ echo "<option value=\"null\">{$lang['strnull']}</option>\n";
+ echo "<option value=\"emptystring\">{$lang['stremptystring'] }</option>\n";
echo "</select>\n</td>\n</tr>\n";
echo "<tr><th class=\"data left required\">{$lang['strfile']}</th>";
echo "<td><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$max_size}\" />\n";