У меня есть проблема в ORH Kohana при загрузке объектов детьми.
Мои таблицы базы данных выглядит, что:Kohana orm - получить объект ребенка и большого ребенка
-objects (something like "houses", but objects sounds better in my opinion)
-id
-name
-title
-author
-city (id link to cities.city_id)
-description
-access
-cities
-city_id
-country (id link to countries.country_name)
-city_name
-countries
-country_id
-country_name
и мои модели:
class Model_Object extends ORM
{
protected $_table_name = 'objects';
protected $_table_columns = array(
'id' => NULL,'name' => NULL,
'title' => NULL,
'author' => NULL,
'city' => NULL,
'description' => NULL,
'access' => NULL,
'created' => NULL
);
protected $_primary_key = 'id';
protected $_has_one = array(
'city'=>array(),
'author'=>array(
'model'=>'User',
'foreign_key'=>'user_id',
)
);
}
class Model_City extends ORM
{
protected $_table_name = 'cities';
protected $_table_columns = array('city_id'=>NULL,'city_name'=>NULL);
protected $_primary_key = 'city_id';
protected $_has_one = array('country'=>array(
'model'=>'country',
'foreign_key'=>'country',
));
protected $_belongs_to = array(
'objects'=>array(),
);
}
class Model_Country extends ORM
{
protected $_table_name = 'countries';
protected $_table_columns = array(
'country_id'=>NULL,
'country_name'=>NULL,
);
protected $_primary_key = 'country_id';
protected $_belongs_to = array(
'cities'=>array(
'model' => 'city',
'foreign_key' => 'country'
),
);
}
Мне нужно получить объект объекта, включая название страны и города. Я нашел это:
ORM::factory('Object')->with('City')->with('City:Country')->find_all();
here но он возвращает города идентификаторы вместо городов объектов.
Итак, мой вопрос: как получить объекты объекта с дочерними объектами в представленных таблицах?