Cakephp save array

What would be an efficient way to save the next array using php (cakephp)? should each value enter a new row in the table?

Array ( [0] => 6786754654 [1] => 5643564545 [2] => 344544545 [3] => 233245654654 [4] => 453454654654 [5] => 6546542323 [6] => 654654654 [7] => 645654654 etc.... ) 

thanks

0
source share
1 answer

2 options:

  • Format the array as requested by Model :: saveAll ()
  • Scroll through the array by calling Model :: create (), then Model: save ()

I would recommend option 1, as you can use Model :: saveAll ($ data, array ('validate' => 'first')); so that all values ​​are valid until any of them are saved.

+4
source

Source: https://habr.com/ru/post/904795/


All Articles