+
+ protected static function saveBatch($entries, $flags)
+ {
+ $table = null;
+ foreach ($entries as $entry) {
+ if (is_null($table)) {
+ $table = $entry->table;
+ } else {
+ Platal::assert($table === $entry->table, "Cannot save batch of entries of different kinds");
+ }
+ if (!$entry->preSave()) {
+ return false;
+ }
+ }
+ $table->saveEntries($entries, $flags);
+ foreach ($entries as $entry) {
+ $entry->changed->clear();
+ $entry->postSave();
+ }
+ return true;
+ }
+
+ public static function insertBatch($entries, $allowUpdate = false)
+ {
+ $flags = PlDBTable::SAVE_INSERT_MISSING;
+ if ($allowUpdate) {
+ $flags |= PlDBTable::SAVE_UPDATE_EXISTING;
+ }
+ return self::saveBatch($entries, $flags);
+ }