FuelPHP Bin
<?php //---------------------------- namespace User\Model; class User extends \Orm\Model { protected static $_properties = array('id', 'nick', 'pass', 'mail', 'token', 'active', 'created_at'); protected static $_has_many = array( 'news' => array( 'model_to' => 'News\Model\News', ), ); protected static $_to_array_exclude = array( 'pass', 'mail', 'token', ); } //--------------------------- namespace News\Model; class News extends \Orm\Model { protected static $_properties = array('id', 'title', 'content', 'author_id', 'publish', 'created_at', 'edited_at'); protected static $_belongs_to = array( 'user' => array( 'key_from' => 'author_id', 'model_to' => 'User\Model\User' )); protected static $_has_many = array( 'comments' => array( 'key_from' => 'id', 'model_to' => 'News\Model\Comments', 'key_to' => 'news_id', 'cascade_save' => true, 'cascade_delete' => true, )); protected static $_many_many = array( 'categories' => array( 'key_from' => 'id', 'key_through_from' => 'newsid', 'table_through' => 'news_categories', 'key_through_to' => 'categorieid', 'model_to' => 'News\Model\Categories', 'key_to' => 'id', )); } //--------------------------- namespace News\Model; class Comments extends \Orm\Model { protected static $_properties = array('id', 'content', 'author_id', 'news_id'); protected static $_belongs_to = array( 'news' => array( 'key_from' => 'news_id', 'model_to' => 'News\Model\News' ), 'user' => array( 'key_from' => 'author_id', 'model_to' => 'User\Model\User' ), ); } //-------------------------- namespace News\Controller; use Fuel\Core\Controller; use Fuel\Core\Request; use Fuel\Core\Response; use Parser\View_Smarty; class News extends Controller { private $data; public function before() { \Fuel\Core\Module::load('user'); parent::before(); } public function action_index() { $news = \News\Model\News::find('all', array('related' => array('user', 'comments', 'comments.user'))); foreach ($news as $n) { $this->data['news'][] = $n->to_array(); } // $this->data['news'] = $news; //this one works (object) but sends allong password etc. from the user model \Firephp\Debug::dump($this->data['news']); return Response::forge(View_Smarty::forge('index_1.tpl', $this->data)); } } //----------------------- //OUTPUT array( [0] => array( ['id'] => 1 ['title'] => 'news1' ['content'] => 'news1 Content <p>blub<p>' ['author_id'] => 1 ['publish'] => 1 ['created_at'] => 11111 ['edited_at'] => 11111 ['user'] => array( ['id'] => 1 ['nick'] => 'Nachtmahr' ['active'] => 1 ['created_at'] => 111111 ) ['comments'] => array( [1] => array( ['id'] => 1 ['content'] => 'comments 1 asdasd' ['author_id'] => 1 ['news_id'] => 1 ['user'] => array( ['id'] => 1 ['nick'] => 'Nachtmahr' ['active'] => 1 ['created_at'] => 111111 ) ) [2] => array( ['id'] => 2 ['content'] => 'comment 2 asdasd' ['author_id'] => 1 ['news_id'] => 1 ) ) ) [1] => array( ['id'] => 2 ['title'] => 'news2' ['content'] => 'news2 asd Content <p>blub<p>' ['author_id'] => 1 ['publish'] => 1 ['created_at'] => 11111 ['edited_at'] => 11111 ['user'] => array( ['id'] => 1 ['nick'] => 'Nachtmahr' ['active'] => 1 ['created_at'] => 111111 ) ['comments'] => array( [1] => array( ['id'] => 1 ['content'] => 'comments 1 news 2 asdasd' ['author_id'] => 2 ['news_id'] => 2 ) [2] => array( ['id'] => 2 ['content'] => 'comment 2 news 2 asdasd' ['author_id'] => 1 ['news_id'] => 2 ) ) ) );