class Controller_Plan extends Controller_Common { public function action_show() { $plan = Model_Plan::find('all', array( 'related' => array('planrecords'), 'where' => array( array('id', '=', Uri::segment(3)), ), )); } }
class Model_Plan extends Orm\Model { protected static $_has_many = array('planrecords'=> array( 'key_from' => 'id', 'key_to' => 'plan_id', )); protected static $_observers = array( 'Orm\\Observer_CreatedAt' => array('before_insert'), 'Orm\\Observer_UpdatedAt' => array('before_save'), ); }
class Model_Planrecord extends Orm\Model { protected static $_belongs_to = array('plan'); }
array(1) { [1]=> object(Model_Plan)#14 (7) { ["_is_new":"Orm\Model":private]=> bool(false) ["_frozen":"Orm\Model":private]=> bool(false) ["_data":"Orm\Model":private]=> array(6) { ["id"]=> string(1) "1" ["created_at"]=> string(19) "2011-04-25 09:35:13" ["updated_at"]=> string(19) "2011-04-25 09:35:13" [...] ["_data_relations":"Orm\Model":private]=> array(1) { ["planrecords"]=> array(2) { [1]=> object(Model_Planrecord)#15 (7) { ["_is_new":"Orm\Model":private]=> bool(false) ["_frozen":"Orm\Model":private]=> bool(false) ["_data":"Orm\Model":private]=> array(13) { ["id"]=> string(1) "1" ["created_at"]=> string(19) "2011-04-25 09:17:58" ["updated_at"]=> string(19) "2011-04-25 09:17:58" ["plan_id"]=> string(1) "1" ["user_id"]=> string(1) "1" ["pos"]=> string(1) "1" ["task_name"]=> string(46) "Initiate Code-Freeze for main repository" [...]
$plan->planrecords;failed. Additionally I am a bit surprised that the result is sort of an array. Could anyone help me? Maybe my queries are wrong? Thanks in advance,
public function action_show() { $plan = Model_Plan::find('first', array( 'related' => array('planrecords'), 'where' => array( array('id', '=', Uri::segment(3)), ), )); }
It looks like you're new here. If you want to get involved, click one of these buttons!