Reputation: 5208
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.
DB::insert
, DB::update
) (this is the best practice -> handling data operations from models) the fields corresponding to the declaration are NOT updating.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
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
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