Skip to content

Commit

Permalink
Code comment
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 13, 2018
1 parent 1e635cf commit e5cc4ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions htdocs/core/modules/import/import_csv.modules.php
Expand Up @@ -633,6 +633,7 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma
//print 'listfields='.$listfields.'<br>listvalues='.$listvalues.'<br>';

// If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined
// so we can try to make the insert or update now.
if (! $errorforthistable)
{
//print "$alias/$tablename/$listfields/$listvalues<br>";
Expand All @@ -644,7 +645,7 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma
if (!empty($updatekeys)) {
// We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields)

if (empty($lastinsertid)) {
if (empty($lastinsertid)) { // No insert done yet for a parent table
$sqlSelect = 'SELECT rowid FROM '.$tablename;

$data = array_combine($listfields, $listvalues);
Expand Down Expand Up @@ -680,10 +681,11 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma
$error++;
}
} else {
// We have a last INSERT ID. Check if we have a row referencing this foreign key.
// We have a last INSERT ID (got by previous pass), so we check if we have a row referencing this foreign key.
// This is required when updating table with some extrafields. When inserting a record in parent table, we can make
// a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record
// may already exists. So we rescan the extrafield table to be know if record exists or not for the rowid.
// may already exists. So we rescan the extrafield table to know if record exists or not for the rowid.
// Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object'
$sqlSelect = 'SELECT rowid FROM '.$tablename;

if(empty($keyfield)) $keyfield = 'rowid';
Expand Down
7 changes: 5 additions & 2 deletions htdocs/core/modules/import/import_xlsx.modules.php
Expand Up @@ -656,6 +656,7 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma
//print 'listfields='.$listfields.'<br>listvalues='.$listvalues.'<br>';

// If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined
// so we can try to make the insert or update now.
if (! $errorforthistable)
{
//print "$alias/$tablename/$listfields/$listvalues<br>";
Expand All @@ -665,7 +666,8 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma
$insertdone = false;
if (!empty($updatekeys)) {
// We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields)
if (empty($lastinsertid)) {

if (empty($lastinsertid)) { // No insert done yet for a parent table
$sqlSelect = 'SELECT rowid FROM '.$tablename;

$data = array_combine($listfields, $listvalues);
Expand Down Expand Up @@ -704,7 +706,8 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma
// We have a last INSERT ID. Check if we have a row referencing this foreign key.
// This is required when updating table with some extrafields. When inserting a record in parent table, we can make
// a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record
// may already exists. So we rescan the extrafield table to be know if record exists or not for the rowid.
// may already exists. So we rescan the extrafield table to know if record exists or not for the rowid.
// Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object'
$sqlSelect = 'SELECT rowid FROM '.$tablename;

if(empty($keyfield)) $keyfield = 'rowid';
Expand Down

0 comments on commit e5cc4ae

Please sign in to comment.