Skip to content

Commit b3754d2

Browse files
committed
Merge pull request #415 from avbdr/master
issue #375. onDuplicate returns false when there was no change in data
2 parents 7b250d8 + 60b7054 commit b3754d2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

MysqliDb.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,12 +1035,17 @@ private function _buildInsert($tableName, $insertData, $operation)
10351035

10361036
$this->_query = $operation . " " . implode(' ', $this->_queryOptions) . " INTO " . self::$prefix . $tableName;
10371037
$stmt = $this->_buildQuery(null, $insertData);
1038-
$stmt->execute();
1038+
$status = $stmt->execute();
10391039
$this->_stmtError = $stmt->error;
1040+
$haveOnDuplicate = !empty ($this->_updateColumns);
10401041
$this->reset();
10411042
$this->count = $stmt->affected_rows;
10421043

10431044
if ($stmt->affected_rows < 1) {
1045+
// in case of onDuplicate() usage, if no rows were inserted
1046+
if ($status && $haveOnDuplicate) {
1047+
return true;
1048+
}
10441049
return false;
10451050
}
10461051

0 commit comments

Comments
 (0)