You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Too bad the non default connection is not read from the instance of the model.
\App\Model::on('otherconnection')->getModel()->insertOnDuplicateKey([[....]]); // will still use the default connection
when rewriting the function to a non static, the instance settings are available.
public function insertOnDuplicateKey(array $data, array $updateColumns = null)
{
if (empty($data)) {
return false;
}
// Case where $data is not an array of arrays.
if (!isset($data[0])) {
$data = [$data];
}
$sql = self::buildInsertOnDuplicateSql($data, $updateColumns);
$data = self::inLineArray($data);
return $this->getConnection()->affectingStatement($sql, $data);
}
The text was updated successfully, but these errors were encountered:
I'm having the same issue -- I can't create a new model because the table name is determined dynamically at runtime. (I'm bulk inserting into a temporary table).
The issues seems to be here:
public static function getTableName()
{
$class = get_called_class();
return (new $class())->getTable();
}
Copied from: #7
@yadakhov Thank you for creating this plugin.
Too bad the non default connection is not read from the instance of the model.
when rewriting the function to a non static, the instance settings are available.
The text was updated successfully, but these errors were encountered: