我是codeigniter&的新手php,我对join()函数有一些疑问。 我有这个模型:
public function get_categorie()
{
$this->db->select('*');
$this->db->from('foxCategory');
$this->db->join('foxAnnunci', 'foxCategory.id = foxAnnunci.id_foxCategory');
$query = $this->db->get();
}
这个控制器:
public function index()
{
$data['category']= $this->annunci_model->get_categorie();
$data['annunci'] = $this->annunci_model->get_annunci();
$data['titolo'] = 'Elenco annunci';
$this->load->view('templates/header', $data);
$this->load->view('annunci/index', $data);
$this->load->view('templates/footer');
}
和这个观点
<h2><?php echo $value['titolo'] ?></h2>
<div id="main">
<code>Data di creazione: <?php echo $value['creato_il'] ?></code><br />
<?php echo $value['descrizione'] ?>
</div>
<p><a href="<?php echo $value['id'] ?>">Guarda annuncio || <p><?php echo $category['category']['titolo'] ?></p></a></p>
我想将类别名称显示为链接(博客类别功能的经典),但此代码什么都没显示,有什么问题?