From 34e29f5840a99e37f9efbcfe4dc93da7efe2e95d Mon Sep 17 00:00:00 2001 From: dr-matt-smith Date: Tue, 8 Feb 2022 13:23:58 +0000 Subject: [PATCH] added insertMany() method --- .DS_Store | Bin 6148 -> 6148 bytes CHANGELOG.md | 24 +++--------------------- src/DatabaseTableRepository.php | 12 ++++++++++++ 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.DS_Store b/.DS_Store index 8cdfedd0f52ea5c3ee94d3dc1c92778c6229ea2e..51de8aa66b409b02e3516861dc47712e89098912 100644 GIT binary patch delta 30 mcmZoMXfc@J&&abeU^gQp&tx8^>c#BLtP=|wHnVg5UvfNJ%&t%6oyoW#GG`);N<+=0tPS;SqG$$WOMUf sT#|C~lYpWe*?<0fC)gfxL|2hQKt(|YvJDA9?VH<}7+E*7bNuB80KRl3^Z)<= diff --git a/CHANGELOG.md b/CHANGELOG.md index 871d281..e3a99a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,31 +8,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip not sure all seems to be working nicely .... ### Added -added reflection to infer SQL to create table from property types, if no SQL provided as constant or as argument to DatabaseTableRepository::createTable() - -so no need for constant like this in an entity class - -```php - class Movie - { - const CREATE_TABLE_SQL = - <<)' to DatabaseTableRespository + +to make fixture insertion a bit easier :-) ### Deprecated -solved deprecation warning -replaced FILTER_SANITIZE_STRING with trim() for variable $simpleKey -in class Mattsmithdev\PdoCrudRepo\DatatbaseUtility::removeNamespacesFromKeys() - line 87 ### Fixed -- updated README - to highlight no need for SQL create table constant any more ### Removed - Nothing diff --git a/src/DatabaseTableRepository.php b/src/DatabaseTableRepository.php index 3b9cba3..fd05107 100644 --- a/src/DatabaseTableRepository.php +++ b/src/DatabaseTableRepository.php @@ -249,6 +249,18 @@ public function insert($object) } } + /** + * given an array of object, loop through them and insert them each into the DB table + * + * @param array $objects] + */ + public function insertMany(array $objects) + { + foreach($objects as $object){ + $this->insert($object); + } + } + /** * insert new record into the DB table