Skip to content

Commit c93a063

Browse files
authored
Merge pull request #1788 from hashtopolis/fix-init-user-check
Fix check for setup on agent table instead of user table
2 parents 030e35d + e3d4459 commit c93a063

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/dba/AbstractModelFactory.class.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,13 @@ public function massSave(array $models): bool|PDOStatement {
372372
$keys = self::getMappedModelKeys($models[0]);
373373
$query = "INSERT INTO " . $this->getMappedModelTable();
374374

375-
array_splice($keys, 0, 1);
375+
$pkInclude = false;
376+
if ($models[0]->getId() !== -1 && $models[0]->getId() !== null) {
377+
$pkInclude = true;
378+
}
379+
else {
380+
array_splice($keys, 0, 1);
381+
}
376382

377383
$query .= " (" . implode(",", $keys) . ") ";
378384
$placeHolder = " (" . implode(",", array_fill(0, count($keys), "?")) . ")";
@@ -385,7 +391,9 @@ public function massSave(array $models): bool|PDOStatement {
385391
$query .= ", ";
386392
}
387393
$dict = $models[$x]->getKeyValueDict();
388-
array_splice($dict, 0, 1);
394+
if (!$pkInclude) {
395+
array_splice($dict, 0, 1);
396+
}
389397
foreach ($dict as $val) {
390398
$vals[] = $val;
391399
}

src/inc/load.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
die("Database connection failed!");
6868
}
6969
try {
70-
Factory::getUserFactory()->filter([], true);
70+
Factory::getAgentFactory()->filter([], true);
7171
}
7272
catch (PDOException $e) {
7373
$query = file_get_contents(dirname(__FILE__) . "/../install/hashtopolis.sql");

0 commit comments

Comments
 (0)