cakephp get data from two tables -
i have model class fooditem needs retrieve datas joining tables menu_food_item. code.
$fooditems=$this->fooditem->find('all',array('joins'=>array(array('table'=>'menu_food_items', 'alias'=>'mfi', 'type'=>'inner', 'forignkey'=>false, 'conditions'=>array('mfi.food_item_id=fooditem.id','mfi.menu_id'=>$menu_id))),'fields'=>array('fooditem.id','fooditem.food_item_title','fooditem.active','mfi.menu_id')));
i want menu_id result.(from menu_food_item table) pr($fooditems); result
array ( [0] => array ( [fooditem] => array ( [id] => b102 [food_item_title] => prown cocktail [active] => 1 ) [mfi] => array ( [menu_id] => 2 ) ) )
but json_encoded result shows fooditems table data only.no menu_food_item(mfi) data. why that? want show menu_id result
you extracting food items here, give array
array ( [0] => array ( [fooditem] => array ( [id] => b102 [food_item_title] => prown cocktail [active] => 1 ) ) )
please remove $fooditems=set::extract('/fooditem/.', $fooditems);
, try.
Comments
Post a Comment