Skip to content

Commit f633a86

Browse files
Merge pull request #13 from genealogiawebsite/optimse
Bulk inserts.
2 parents 53ea044 + f3a9b4a commit f633a86

File tree

7 files changed

+597
-36
lines changed

7 files changed

+597
-36
lines changed

src/Utils/Importer/Indi/Alia.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public static function read($conn, $item, $group = '', $group_id = 0)
2020
$aliaData[] = $data;
2121
}
2222
}
23-
PersonAlia::insert($aliaData);
23+
PersonAlia::on($conn)->insert($aliaData);
2424
}
2525
}

src/Utils/Importer/Indi/Even.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,28 @@ public static function read($conn, $events, $person, $obje_ids = [])
117117
break;
118118
default:
119119
}
120-
$adop = '';
121-
$adop_famc = '';
122-
$birt_famc = '';
123-
// store Even
124-
$key = [
125-
['person_id', $person_id],
126-
['title', $class_name],
127-
['type', $type],
128-
['attr', $attr],
129-
['date', $date],
130-
['plac', $plac],
131-
['phon', $phon],
132-
['caus', $caus],
133-
['age', $age],
134-
['agnc', $agnc],
135-
['adop', $adop],
136-
['adop_famc', $adop_famc],
137-
['birt_famc', $birt_famc],
138-
];
139-
$check = PersonEvent::where($key)->first();
140-
if (empty($check)) {
120+
$adop = '';
121+
$adop_famc = '';
122+
$birt_famc = '';
123+
// store Even
124+
$key = [
125+
['person_id' , $person_id],
126+
['title' , $class_name],
127+
['type' , $type],
128+
['attr' , $attr],
129+
['date' , $date],
130+
['plac' , $plac],
131+
['phon' , $phon],
132+
['caus' , $caus],
133+
['age' , $age],
134+
['agnc' , $agnc],
135+
['adop' , $adop],
136+
['adop_famc' , $adop_famc],
137+
['birt_famc' , $birt_famc]
138+
];
139+
$check = PersonEvent::on($conn)->where($key)->first();
140+
if(empty($check)){
141+
141142
$data = [
142143
'person_id' => $person_id,
143144
'title' => $class_name,
@@ -159,9 +160,9 @@ public static function read($conn, $events, $person, $obje_ids = [])
159160
}
160161
}
161162
}
162-
PersonEvent::insert($eventData);
163-
$new = new Even();
164-
$new->otherField($conn, $events, $person);
163+
PersonEvent::on($conn)->insert($eventData);
164+
$new = new Even;
165+
$new->otherField($conn,$events,$person);
165166
}
166167

167168
public static function otherField($conn, $events, $person)
@@ -287,7 +288,7 @@ public static function otherField($conn, $events, $person)
287288
['birt_famc', $birt_famc],
288289
];
289290

290-
$record = PersonEvent::where($key)->first();
291+
$record = PersonEvent::on($conn)->where($key)->first();
291292

292293
$_group = 'indi_even';
293294
$_gid = $record->id;

src/Utils/Importer/Indi/Subm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public static function read($conn, $item, $group = '', $group_id = 0, $subm_ids)
2626
}
2727
}
2828

29-
PersonSubm::insert($record);
29+
PersonSubm::on($conn)->insert($record);
3030
}
3131
}

src/Utils/ParentData.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ public static function getPerson($conn, $individuals, $obje_ids)
100100
// $person = Person::on($conn)->updateOrCreate($key,$value);
101101
// otherFields::insertOtherFields($conn,$individual,$obje_ids,$person);
102102
}
103-
104-
Person::insert($ParentData);
105-
otherFields::insertOtherFields($conn, $individuals, $obje_ids);
103+
foreach (array_chunk($ParentData, 200) as $chunk)
104+
{
105+
Person::on($conn)->insert($chunk->toArray());
106+
}
107+
otherFields::insertOtherFields($conn,$individuals,$obje_ids);
106108
}
107109
}

0 commit comments

Comments
 (0)