[eluser]frist44[/eluser]
I'm trying to iterate through an object in a view. So my controller has:
Code:
$o = new Order();
$o->get();
$o->product->get();
In my view:
Code:
foreach ($obj as $order){
echo '<tr>';
echo '<td>' . $order->id . '</td>';
echo '<td>' . $order->product->id . $order->product->finish . '</td>';
echo '<td>' . $order->quantity . '</td>';
echo '<td>' . $order->reconciled . '</td>';
echo '<td>' . mysql_datetime_to_php($order->created) . '</td>';
echo '</tr>';
}
But $order->product->id, doesn't show up. if I do :
foreach ($obj->product as $product), I can get the info out. Why isn't the deeper relationships passed through with the foreach variable?
Instead, it seems I have to dig through each one on the loop:
Code:
foreach ($obj as $order){
$p = new Product();
echo '<tr>';
echo '<td>' . $order->id . '</td>';
echo '<td>' . $p->get_by_id($order->product_id)->geometry . '-' . $p->get_by_id($order->product_id)->finish . '</td>';
echo '<td>' . $order->quantity . '</td>';
echo '<td>' . show_reconcile($order->reconciled) . '</td>';
echo '<td class="textleft">' . mysql_datetime_to_php($order->created) . '</td>';
echo '</tr>';
}
Controller:
Code:
$o = new Order();
$o->get_iterated();
$o->product->get();
$data['obj'] = $o;