kohana ---- auto insert

160 Views Asked by At

How to insert same data into database after update in ORM? For example i have function save() and inside this function i have update and it's working, but i don't know how to make insert with old update data. I mean it should make something like history in database. I only hope you can understand what i mean. Thanks for help.

public function save(Validation $validation = NULL)
{
    if ($this->loaded()) {
        // UPDATE TRIGGER

        DB::update($this->_table_name)
            ->set(array('ud_status' => 'D'))
            ->where('ud_status', '=', 'A')
            ->where('ud_uId', '=', $this->ud_uId)
            ->execute($this->_db);

        return false;
    } else {
        // INSERT TRIGGER
        return parent::save($validation);
    }
}
1

There are 1 best solutions below

1
MisterX On
$query = DB::insert('users', array('username', 'password'))->values(array('fred', 'p@5sW0Rd'));

https://kohanaframework.org/3.3/guide/database/query/builder#insert