# Registering Multiple Records there mysql the same rate using CakePHP 3x

**URL:** <https://discourse.cakephp.org/t/registering-multiple-records-there-mysql-the-same-rate-using-cakephp-3x/865>\
**Category:** Need Help\
**Created:** [August 1, 2016, 9:19pm UTC](https://discourse.cakephp.org/t/registering-multiple-records-there-mysql-the-same-rate-using-cakephp-3x/865 "2016-08-01T21:19:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Janlon](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@Janlon](https://discourse.cakephp.org/u/Janlon)\
**Post date:** [August 1, 2016, 9:19pm UTC](https://discourse.cakephp.org/t/registering-multiple-records-there-mysql-the-same-rate-using-cakephp-3x/865/1 "2016-08-01T21:19:58Z")

</div>

I’m trying to do an insert using the resources of CakePhp . I would like the query output to be like this :

`INSERT INTO`image`(`type`,`file`, fileDir) VALUES ( 'jpg', 'image1','webroot/img/jpg'), ('png', 'image2','webroot/img/png'), ('gif', 'image3','webroot/img/gif').`

In fact , I’m using a FOR loop , which is more or less like this:  
for($i =0; $i \> count($new[0]); $i++)  
{  
$entity = $this-\>Model-\>patchEntity($entity, $new[0][$i]);  
$this-\>Model-\>save($entity);  
}

---

<div class="post-metadata">

**Author:** ![Tao](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/tao/32/340_2.png) [@Tao](https://discourse.cakephp.org/u/Tao)\
**Post date:** [August 2, 2016, 6:21am UTC](https://discourse.cakephp.org/t/registering-multiple-records-there-mysql-the-same-rate-using-cakephp-3x/865/2 "2016-08-02T06:21:08Z")

</div>

Well, you can make many entities and save many like this:

```auto
$images = $this->Model->newEntities($imageDatas);
$this->Model->saveMany($images);

```

---

<div class="post-metadata">

**Author:** ![Janlon](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@Janlon](https://discourse.cakephp.org/u/Janlon)\
**Post date:** [August 2, 2016, 9:13pm UTC](https://discourse.cakephp.org/t/registering-multiple-records-there-mysql-the-same-rate-using-cakephp-3x/865/3 "2016-08-02T21:13:21Z")

</div>

Perfect. I managed using the example and perfecting with this :

$data = [  
[  
‘title’ =\> ‘First post’,  
‘published’ =\> 1  
],  
[  
‘title’ =\> ‘Second post’,  
‘published’ =\> 1  
],  
];  
$articles = TableRegistry::get(‘Articles’);  
$entities = $articles-\>newEntities($data);  
$result = $articles-\>saveMany($entities);

$this-\>Solved;
