Skip to content

Commit

Permalink
added insertMany() method
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-matt-smith committed Feb 8, 2022
1 parent 16e98de commit 34e29f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
Binary file modified .DS_Store
Binary file not shown.
24 changes: 3 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
<<<HERE
CREATE TABLE IF NOT EXISTS movie (
id integer PRIMARY KEY AUTO_INCREMENT,
title text,
price float,
category text
)
HERE;
```
added new method 'insertMany(<array>)' 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
Expand Down
12 changes: 12 additions & 0 deletions src/DatabaseTableRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34e29f5

Please sign in to comment.