dana
dana

Reputation: 5208

Kohana 3.0.4 ORM $_created_column $_updated_column

I have a problem in my model declaration, in Kohana 3.0.4 with the fields $_created_column and $_updated_column. The problem is that : - When I create and update objects from my controllers, the fields in the database corresponding to $_created_column and $_updated_column declaration are modified, according to the current create/modification date, just as it should be.

The code for DB::update and DB::insert:

    public function add_productimage($zoom, $particular, $thumbnail, $presentation, $product, $order){   
    $insert_id = DB::insert('product_image', array('zoom','particular','thumbnail','presentation','product','order'))
        ->values(array($zoom, $particular, $thumbnail,$presentation, $product, $order))
        ->execute();
    return $insert_id;
}

Any idea why?

Upvotes: 0

Views: 509

Answers (2)

Tadeck
Tadeck

Reputation: 137370

You are not using ORM for inserts and updates, thus these specific settings are not applied. You use DB Query Builder instead of ORM. Use ORM for inserts / updates and you will be then employing best practice in this case.

By the way: your version of Kohana (3.0.4) should be easily updated to 3.0.12 (the most up-to-date in 3.0.x line), and this will fix multiple bugs that existed in 3.0.4.

Upvotes: 2

matino
matino

Reputation: 17725

First of all I don't see any reason not to use ORM inside your method:

public function add_productimage($post)
{
   $this->values($post);
   $this->save();
}

This is the preffered way to go, since this way you'll have your model validated before saving.

To answer your question - have you tried doing it exactly the same way as docs say?
Oh and also make sure you point to the right table - in your example it's product_image while Kohana style is product_images. Maybe you forgot the add the 's' at the end.

Upvotes: 1

Related Questions