0

I have an array like

Array
(
    [user_id] => 53edcd30-6cf4-4d3c-b5d3-7a76ac14142e
    [training_course_id] => Array
        (
            [0] => 1
            [1] => 3
            [2] => 5
        )

)

Now I want to insert this array into a database table using cakephp. I do not know how to do this. Please help me. I'm new in cakephp.

wayzz
  • 585
  • 6
  • 23
  • What have you tried? Have you searched around for anything? On SO there is this question for example http://stackoverflow.com/questions/11127210/cakephp-saving-data-to-database – Antony D'Andrea Feb 02 '15 at 08:01
  • Read the book for these very basics: http://book.cakephp.org/2.0/en/models/saving-your-data.html – floriank Feb 02 '15 at 08:34

1 Answers1

0

Try this...

$query = $articles->query();
$query->insert(['title', 'body'])
    ->values([
        'title' => 'First post',
        'body' => 'Some body text'
    ])
    ->execute();

Refer:http://book.cakephp.org/3.0/en/orm/query-builder.html http://cakephp.1045679.n5.nabble.com/Custom-Query-Insert-Into-td1286305.html

Deenadhayalan Manoharan
  • 5,436
  • 14
  • 30
  • 50