개체 자식로드시 Kohana ORM에 문제가 있습니다. 나는 국가 및 도시의 이름을 포함하여 객체의 객체를 얻을 필요가Kohana orm - 자식 및 그물 자식 개체 얻기
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'
),
);
}
:
-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
내 모델 :
내 데이터베이스 테이블 것으로 보인다. 나는이 발견
ORM::factory('Object')->with('City')->with('City:Country')->find_all();
here을하지만 대신 도시 객체의 ID 도시를 반환합니다.
제 질문은 : 제시된 테이블에서 자식 개체를 사용하여 개체의 개체를 얻는 방법은 무엇입니까?