Q:

Batch insertion of records in cakephp

Is batch insertion of records   possible in cakephp ?
Kindly reply me if possible show me some samples ?
My Query will look like
INSERT INTO `job_places` (`id`, `country_code`, `group`, `name`) VALUES
 (1, 'DE', 3, 'Hamburg'),
 (6, 'FFF', 1, 'Frankfurt');

A:

You have saveAll for things like this http://book.cakephp.org/1.3/view/1031/Saving-Your-Data

Used to save (a) multiple individual records for a single model or (b) this record, as well as all associated records
  For saving multiple records of single model, $data needs to be a
  numerically indexed array of records like this: 

Array (

>     [Article] => Array(
>           [0] => Array
>               (
>                             [title] => title 1
>                         )
>           [1] => Array
>               (
>                             [title] => title 2
>                         )
>                 ) )

In your example, you'll need to format your data array like:
$data = array(
   'Job' => array(
      array('id' => 1, 'country_code' => 'DE', 'group' => 3, 'name' => 'Hamburg'),
      array('id' => 6, 'country_code' => 'FFF', 'group' => 1, 'name' => 'Frankfurt')
   )
);

$this->JobPlace->saveAll($data['Job']);

Nothing beats trying when you are learning something, so give that a go and post any problems you are having rather than wait for someone to post the exact code where you can just copy paste.

