Saving a multidimensional array to the database doesn't work anymore

Permalink 45 44 Browser Info Environment
In an add-on like the default gallery, typically there are 2 tables with a one to many relationship.
Developers have to take care of saving in the second table manually.

All add-ons I saw usually did that one line at a time. For instance, for the gallery, if you add 5 images, the add-on will save the info concerning the images in the second table one image at a time. That means 5 separate calls to the database.

I thought that was a bit slow so for my ad-on Social Icons Reloaded Pro, I put all the data in a multidimensional array and save it all in one go.

Since the 5.6.2.x update, that throws an error.

The code is as follow
$vals = array();
foreach ($data['item'] as $item) {
$var1= $data['var1'];
$var2= $data['var2'];
$var3= $data['var3'];
$vals[] = array($item, $var1, $var2, $var3);
}
$db->query("INSERT INTO tableName(item, var1, var2, var3) values (?,?,?,?)", $vals);


That works very well all the way up to 5.6.1.2.
Starting from 5.6.2 it throws out the following error:

An unexpected error occurred. mysqlt error: [-9999: Input Array does not match ?: INSERT INTO btSocialIconsReloadedProLinks (bID,fID,is_custom_network,network,link,label,tooltip) values (Array,Array,Array,Array,] in Execute(, )


Status: New

Still Valid:

This bug is valid a newer version of concrete5. View Current Bug
mnakalay

concrete5 Environment Information

# concrete5 Version
5.6.2

# concrete5 Packages
Social Icons Reloaded Pro (1.3.1).

# concrete5 Overrides
blocks/autonav, elements/header_required.php, themes/corac, themes/corac.zip

# Server Software
Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8

# Server API
apache2handler

# PHP Version
5.3.8

# PHP Extensions
apache2handler, bcmath, bz2, calendar, com_dotnet, Core, ctype, curl, date, dom, ereg, exif, filter, ftp, gd, gettext, hash, iconv, imap, json, libxml, mbstring, mcrypt, mhash, mysql, mysqli, mysqlnd, odbc, openssl, pcre, PDO, pdo_mysql, PDO_ODBC, pdo_sqlite, Phar, Reflection, session, SimpleXML, soap, sockets, SPL, SQLite, sqlite3, standard, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib.

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
memory_limit - 128M
post_max_size - 8M
safe_mode - Off
safe_mode_exec_dir - <i>no value</i>
safe_mode_gid - Off
safe_mode_include_dir - <i>no value</i>
sql.safe_mode - Off
upload_max_filesize - 128M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
safe_mode_allowed_env_vars - PHP_
safe_mode_protected_env_vars - LD_LIBRARY_PATH

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36