@@ -17,9 +17,9 @@ This class implements a generic MySQL database access wrapper.
1717 * [ Count rows] ( #count-rows )
1818* Execute UPDATE or INSERT queries from parameters that define the tables, fields, field values and conditions
1919 * [ Array to insert] ( #array-to-insert )
20- * [ Multiple array to insert] ( #array-to-insert )
20+ * [ Multiple array to insert] ( #array-to-insert-multirow )
2121 * [ Array to update] ( #array-to-update )
22- * [ Multiple array to update] ( #array-to-update )
22+ * [ Multiple array to update] ( #array-to-update-multirow )
2323* [ Count the number of rows of a table that match a given condition] ( #count-rows )
2424* [ Delete table rows that match a given condition] ( #delete-rows )
2525* [ Operations with CSV files] ( #operations-with-csv-files )
@@ -442,6 +442,42 @@ $db->arrayToInsert('table', array($data, $data2 /*, $data3 .... */ ));
442442$db->close();
443443```
444444
445+ #### Array to insert multirow
446+ ``` php
447+ $db = MySQL_wrapper::getInstance(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);
448+
449+ // Connect to host
450+ $db->connect();
451+
452+ // Array data
453+ // [fealdname] = feald value
454+ $data = array();
455+
456+ // Data set 1
457+ $data[] = array(
458+ 'firstname' => 'foo',
459+ 'surname' => 'bar',
460+ 'email' => 'hi@radovanjanjic.com',
461+ 'date' => 'now()'
462+ );
463+
464+ // Data set 2
465+ $data[] = array(
466+ 'firstname' => 'baz',
467+ 'surname' => 'qux',
468+ 'email' => 'hi@radovanjanjic.com',
469+ 'date' => 'now()'
470+ );
471+
472+ // Data set ...
473+
474+ // $db->arrayToInsert( ... ) multirow returns TRUE on success
475+ $db->arrayToInsert('table', $data);
476+
477+ // Close connection
478+ $db->close();
479+ ```
480+
445481#### Array to update
446482``` php
447483$db = MySQL_wrapper::getInstance(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);
@@ -500,6 +536,50 @@ $db->arrayToUpdate('table', array($data, $data2 /*, $data3 .... */ ));
500536$db->close();
501537```
502538
539+ #### Array to update multirow
540+ ``` php
541+ $db = MySQL_wrapper::getInstance(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);
542+
543+ // Connect to host
544+ $db->connect();
545+
546+ // Array data
547+ // [fealdname] = feald value
548+ $data = array();
549+
550+ // Data set 1
551+ $data[] = array(
552+
553+ // Condition
554+ 'id' => 1, // One of the fields has to be primary or unique key in order to update
555+
556+ // Data to update
557+ 'firstname' => 'foooo',
558+ 'surname' => 'barrr'
559+ // ...
560+ );
561+
562+ // Data set 2
563+ $data[] = array(
564+
565+ // Condition
566+ 'id' => 2, // One of the fields has to be primary or unique key in order to update
567+
568+ // Data to update
569+ 'firstname' => 'bazzz',
570+ 'surname' => 'quxxx'
571+ // ...
572+ );
573+
574+ // Data set ...
575+
576+ // $db->arrayToUpdate( ... ) multirow returns TRUE on success
577+ $db->arrayToUpdate('table', $data);
578+
579+ // Close connection
580+ $db->close();
581+ ```
582+
503583### Delete row(s)
504584``` php
505585$db = MySQL_wrapper::getInstance(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);
0 commit comments