Answer the question
In order to leave comments, you need to log in
How to change the link key in Kohana 3 ORM?
There are two tables: Orders (id/number/summ/datetime) and Dishes (id/order_number/name/cost)
And there is a link in the order model for selecting dishes
protected $_has_many = array(
'dishes' => array(
'model' => 'dishes',
'foreign_key' => 'order',
),
);
protected $_has_many = array(
'dishes' => array(
'model' => 'dishes',
'foreign_key' => 'order',
'table_id' => 'number' // Этого нет конечно, но чтонибудь типо такого было бы неплохо.
),
);
Answer the question
In order to leave comments, you need to log in
You somehow design the database incorrectly, describe what exactly you want to get as a result . You
can order 1 dish several times, the same thing in 1 order there can be several dishes, i. You need to use the belongs to relationship (many to many)
PS Model names in Kohana are usually referred to in the singular (except for exceptions)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question