Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated insertMulti #775

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions MysqliDb.php
Expand Up @@ -780,6 +780,13 @@ public function insertMulti($tableName, array $multiInsertData, array $dataKeys
$autoCommit = (isset($this->_transaction_in_progress) ? !$this->_transaction_in_progress : true);
$ids = array();

$options = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use old Array() syntax since we still support old php version

'_queryOptions' => $this->_queryOptions,
'_nestJoin' => $this->_nestJoin,
'_forUpdate' => $this->_forUpdate,
'_lockInShareMode' => $this->_lockInShareMode
];

if($autoCommit) {
$this->startTransaction();
}
Expand All @@ -789,6 +796,10 @@ public function insertMulti($tableName, array $multiInsertData, array $dataKeys
// apply column-names if given, else assume they're already given in the data
$insertData = array_combine($dataKeys, $insertData);
}

foreach ($options as $k => $v) {
$this->${'k'} = $v;
}

$id = $this->insert($tableName, $insertData);
if(!$id) {
Expand All @@ -799,14 +810,12 @@ public function insertMulti($tableName, array $multiInsertData, array $dataKeys
}
$ids[] = $id;
}

if($autoCommit) {
$this->commit();
}

return $ids;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove all whitespace changes

/**
* Replace method to add new row
*
Expand Down