Model_Post::find(1)
Model_Post::find('all')
Notice! ErrorException [ Notice ]: Trying to get property of non-object APPPATH/views/post/index.php @ line 2: 1: <div id="id_box"> 2: <?=$thought->id;?> 3: </div> Notice! ErrorException [ Notice ]: Trying to get property of non-object APPPATH/views/post/index.php @ line 5: 4: <div id="title"> 5: <?=$thought->title;?> 6: </div> Notice!
$data['post'] = array( Model_Post::find('all') ); $this->body->response = View::factory('post/all', $data['post']);
$posts = Model_Post::find('all'); var_dump($posts); //should be an array of post objects //traverse these objects like so foreach($posts as $post){ echo "post object id: $post->id"; //or something }
array(1) { [1]=> object(Model_Post)#11 (7) { ["_is_new":"Orm\Model":private]=> bool(false) ["_frozen":"Orm\Model":private]=> bool(false) ["_data":"Orm\Model":private]=> array(5) { ["id"]=> string(1) "1" ["created"]=> string(10) "1313618725" ["title"]=> string(40) "This is the first thought ever made here" ["author"]=> string(4) "Zero" ["content"]=> string(509) "their was a popular post earlier about suicide i just read .. its crazy there was soo much feedback and help from everyone ... it goes to show there was still GOOD people in this fucked up world ... and i thought the world as gone to hell. i am glad to find people that think the same way as me. people i too have fought with depression and suicide. and i wish i had THIS much backing or help. i had to deal with it by my self... you guys def made my night 10 times better .... ONE LOVE ,Brother/SisterHood" } ["_original":"Orm\Model":private]=> array(5) { ["id"]=> string(1) "1" ["created"]=> string(10) "1313618725" ["title"]=> string(40) "This is the first thought ever made here" ["author"]=> string(4) "Zero" ["content"]=> string(509) "their was a popular post earlier about suicide i just read .. its crazy there was soo much feedback and help from everyone ... it goes to show there was still GOOD people in this fucked up world ... and i thought the world as gone to hell. i am glad to find people that think the same way as me. people i too have fought with depression and suicide. and i wish i had THIS much backing or help. i had to deal with it by my self... you guys def made my night 10 times better .... ONE LOVE ,Brother/SisterHood" } ["_data_relations":"Orm\Model":private]=> array(0) { } ["_original_relations":"Orm\Model":private]=> array(0) { } ["_iterable":protected]=> array(0) { } } } 1
Jay Arias wrote on Wednesday 17th of August 2011:I get a DUMP of all the info. I can't select regular things.
that looks fine to me you have an array with 1 entry. The only accessible part of the ORM model is _data You traverse each one like this
foreach($posts as $post){ echo "The title of this post is " . $post->title; }
of course you wouldn't want to do this in the controller but just to show how its done.
It looks like you're new here. If you want to get involved, click one of these buttons!