加入查询与篝火(codeigniter)

I'm trying to do a join query in bonfire (which is great for the beginner i am btw)

I first tried to set a public function in the method, but after a while, i though it would be better to put it in the controller (maybe i'm wrong...?)

However, i guess my join request is valid, but i can't get it in my view...

Here is my controller:

class Patient extends Admin_Controller {

    public function __construct() {
        parent::__construct();

        $this->load->model('post_model');

        Template::set_block('search/search', 'search/search');
        //Template::set('toolbar_title', 'Manage Your Blog');
        Template::set_theme('custom', 'default');
        Template::set_block('nav', 'nav');
    }

    public function detail($id = null) {
        $this->load->helper('typography');
        $this->load->model('operation_model');

        $this->db->select('*');
        //$this->db->from ('operation AS ope');
        $this->db->from('operation');

        $this->db->join('patient', "patient.zkp_pat = operation.zkf_pat ");

        $query = $this->db->get();
        $post = $this->post_model->find($id);

        //Template::set('post', $query);
        Template::set('post', $post);

        Template::set_view('detail');
        Template::render();
    }
}

And my view file:

<code>
    <div class="post">
        <?php
        echo ($post->nom . ' ');
        echo ($post->prenom . ' ');
        echo ($post->zkp_pat . ' ');

        echo ($post->dob);

        foreach ($query as $row) :
            echo ($row->zkf_pat . ' ' );
            echo "titre de l'opération: " . ($row->titre);
        endforeach;
        ?>
    </div>
</code>

Thanks for your advices and help !

I asked for help on the BF forum too, and somebody gave me the solution=>hopefully this will help somebody else. The issue was with the $query , which is a DB_result object. http://www.codeigniter.com/user_guide/database/query_builder.html#selecting-data

to solve the problem i had to doo: $query->result()

Final code:

Controller:

public function detail ($id = null){
    $this->load->helper('typography');


    $this->db->from ('operation as ope');
    $this->db->join ('patient',
                    "patient.zkp_pat = ope.zkf_pat " );
    $this->db->where ('patient.zkp_pat', $id);
    $query = $this->db->get();

    $post = $this->post_model->find($id);

    Template::set('query', $query);
    Template::set('post', $post);


    Template::set_view('detail');
    Template::render()        
}

And view file:

<div class="post">
    <h2><?php e($post->nom); ?></h2>
<?php 
echo ($post->nom . ' '); echo ($post->prenom . ' '); 
echo($post->zkp_pat . ' ');
echo ($post->dob);

foreach ($query->result() as $row) :
    echo '<div>'
    echo " 
"; 
    echo ($row->zkf_pat . '  ');
    echo "titre de l'opération: " . ($row->titre);
?>
    </div>
<?php 
    endforeach;
?>

</div>

$query->get()->result() returns an object with all fetched data, whereas $query->get()->row()returns only a single result row, if the result has one row, it returns only the first one. The result is given as an object...

If you like my edit, please upvote, that would be very helpful !