Commit fdefab23 authored by Sigrid Suski's avatar Sigrid Suski

(!) Possibility to use normalize with insertArray()

parent 1f00467b
......@@ -36,6 +36,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
(+) Recursive file moving/copying added to the DirectoryIterator
(!) Detecting graphics editor depends on WEBP capability
(!) Possibility to use normalize with insertArray()
(#) Fixes for latest MySQL version
(#) FileSystem::Delete() does not always return success status
......
......@@ -769,6 +769,11 @@ class MySQLi
/**
* Creates a "insert" SQL query with multiple values.
* Attention: in normalize is false, all different columns must be set for all rows
* [a,b] and [a,c] from [a,b,c] does not work
* [a,b] and [a,b] from [a,b,c] does work
* [a,b,c] and [a,b,c] from [a,b,c] does not work
* Attention: if normalize is true, non-set values will be cleared in the table!!
*
* @param string $table - table name
* @param array $values - one-dimensional array with two-dimensional array with table row name => value
......@@ -778,7 +783,7 @@ class MySQLi
* @return \Sobi\Database\MySQLi
* @throws Exception
*/
public function & insertArray( $table, $values, $update = false, $ignore = false )
public function & insertArray( $table, $values, $update = false, $ignore = false, $normalize = false )
{
$ignore = $ignore ? 'IGNORE ' : null;
$rows = [];
......@@ -786,6 +791,9 @@ class MySQLi
$v = [];
$vars = [];
$k = [];
if ( $normalize ) {
$this->normalize( $table, $arr );
}
foreach ( $arr as $var => $val ) {
if ( is_array( $val ) || is_object( $val ) ) {
$val = Serialiser::serialise( $val );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment