私が次のものを持っているとしましょう:
$categories = ORM::factory('category')->find_all();
foreach ($categories as $category) :
echo $category->category_title;
foreach ($category->posts->find_all() as $post) :
echo $post->post_title;
endforeach;
endforeach;
それは印刷します:
Category One
Post One
Category Two
Category Three
Post Two
Category Four
Post Three
ギャップは、そこにポストがないことを意味します。
印刷したいものは次のとおりです。
Category One
Post One
Category Two
No Post
Category Three
Post Two
Category Four
Post Three
だから基本的に私は欲しい:
foreach ($posts->find_all() as $post) :
if post exists
echo $post->post_title;
else
No Post
endforeach;
それ、どうやったら出来るの?