mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-02 05:37:56 +02:00
Merge pull request #6507 from marc1706/ticket/12439
[ticket/12439] Unify behavior and deduplicate sql_multi_insert
This commit is contained in:
commit
60c2abdfda
@ -724,38 +724,28 @@ abstract class driver implements driver_interface
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->multi_insert)
|
||||
$ary = array();
|
||||
foreach ($sql_ary as $_sql_ary)
|
||||
{
|
||||
$ary = array();
|
||||
foreach ($sql_ary as $id => $_sql_ary)
|
||||
// If by accident the sql array is only one-dimensional we build a normal insert statement
|
||||
if (!is_array($_sql_ary))
|
||||
{
|
||||
// If by accident the sql array is only one-dimensional we build a normal insert statement
|
||||
if (!is_array($_sql_ary))
|
||||
{
|
||||
return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary));
|
||||
}
|
||||
return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary));
|
||||
}
|
||||
|
||||
// Add values to set to $ary if multi insert is supported, otherwise run every insert query separately
|
||||
if ($this->multi_insert)
|
||||
{
|
||||
$values = array();
|
||||
foreach ($_sql_ary as $key => $var)
|
||||
foreach ($_sql_ary as $var)
|
||||
{
|
||||
$values[] = $this->_sql_validate_value($var);
|
||||
}
|
||||
$ary[] = '(' . implode(', ', $values) . ')';
|
||||
}
|
||||
|
||||
return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($sql_ary as $ary)
|
||||
else
|
||||
{
|
||||
if (!is_array($ary))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary));
|
||||
|
||||
$result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $_sql_ary));
|
||||
if (!$result)
|
||||
{
|
||||
return false;
|
||||
@ -763,6 +753,11 @@ abstract class driver implements driver_interface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->multi_insert)
|
||||
{
|
||||
return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user