Witam. Mam pewien problem z pobieraniem danych przez ORM, wszystko działa tak jak powinno tylko chce dodać coś nietypowego, a nie wiem jak się za to zabrać.
Kontroler
public function action_index()
{
$items = ORM::factory('item')
->with('combination')
->with('image')
->find_all();
$this->template->content = View::factory('all')->set('items', $items);
echo View
::factory('profiler/stats'); }
Model Item
class Model_Item extends ORM {
protected
$_belongs_to = array('combination' => array( 'model' => 'combination',
'foreign_key' => 'combination_id'),
'model' => 'image',
'foreign_key' => 'image_id'));
}
Model Image
class Model_Image extends ORM {
}
Model Combination
class Model_Combination extends ORM {
protected
$_belongs_to = array('item' => array());
}
i widok
<div class="items">
<?php foreach($items as $post):?>
<div class="lp">
<?php echo $post->id ?></div>
<div class="tekst">
<?php echo $post->name ?></div>
<div class="pictures"><a class="items"><img src="
<?php echo url
::base().'media/pictures/'.$post->image->url ?>" border="1"></a></div>
<div class="tooltip">
<img src="
<?php echo url
::base().'media/pictures/'.$post->image->url ?>" style="float:left;margin:0px 0px 0px 0px" />
<table style="margin:0">
<tr><td class="label">Nazwa:</td><td>
<?php echo $post->name ?></td></tr>
<tr><td class="label">Kombinacja:</td><td>
<?php echo $post->combination->id_one .' + '. $post->combination->id_two ?></td></tr>
</table>
</div>
w widoku
$post->combination->id_one
jak i
$post->combination->id_two
zawierają różne id które teraz mi się wyświetlają jako cyfry, problem mój polega na tym że chciałbym aby te id_one i id_two zostało zastąpione przez odpowiedni $post->name, jak to najlepiej wykonać?
Pozdrawiam