K
K
Kirill Gorlov2015-06-24 12:52:14
ORM
Kirill Gorlov, 2015-06-24 12:52:14

How to overwrite primary_key in Kohana 3?

Available model

class Model_Order extends ORM {

  protected $_table_name = 'orders';
  protected $_primary_key = 'number';
.......................
}

Since the number field is the Primary Key, I myself cannot change this field using the write method using
ORM::factory('order')->values(array(
'number' => 123456
))->create();

This field is set to 0, no matter how hard I try.
Also in the model there is an ID with autoincrement, which was the Primary Key before, but according to the structure, it is necessary that number be the Primary Key.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question