CSV import : refactor SQL insert construction
This commit is contained in:
parent
3d72f788b9
commit
de62e4cdb8
@ -558,21 +558,21 @@ class ImportCsv extends ModeleImports
|
|||||||
{
|
{
|
||||||
//var_dump($objimport->array_import_convertvalue); exit;
|
//var_dump($objimport->array_import_convertvalue); exit;
|
||||||
|
|
||||||
// Build SQL request
|
// Build SQL UPDATE request
|
||||||
if (empty($tablewithentity_cache[$tablename]))
|
$sqlstart = 'UPDATE '.$tablename;
|
||||||
{
|
|
||||||
$sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key';
|
// Build SQL INSERT request
|
||||||
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias];
|
$sqlstart = 'INSERT INTO '.$tablename.'('.$listfields.', import_key';
|
||||||
$sql.=') VALUES('.$listvalues.", '".$importid."'";
|
$sqlend = ') VALUES('.$listvalues.", '".$importid."'";
|
||||||
|
if (! empty($tablewithentity_cache[$tablename])) {
|
||||||
|
$sqlstart.= ', entity';
|
||||||
|
$sqlend.= ', '.$conf->entity;
|
||||||
}
|
}
|
||||||
else
|
if (! empty($objimport->array_import_tables_creator[0][$alias])) {
|
||||||
{
|
$sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias];
|
||||||
$sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key, entity';
|
$sqlend.=', '.$user->id;
|
||||||
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias];
|
|
||||||
$sql.=') VALUES('.$listvalues.", '".$importid."', ".$conf->entity ;
|
|
||||||
}
|
}
|
||||||
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$user->id;
|
$sql = $sqlstart.$sqlend.')';
|
||||||
$sql.=')';
|
|
||||||
dol_syslog("import_csv.modules", LOG_DEBUG);
|
dol_syslog("import_csv.modules", LOG_DEBUG);
|
||||||
|
|
||||||
//print '> '.join(',',$arrayrecord);
|
//print '> '.join(',',$arrayrecord);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user