0

我正在尝试向此函数添加类别参数:

    public function get_prog_channel($chaine_id = NULL, $nb = NULL, $debut = NULL) {
    $q = $this->db->select('*');
    $q->from($this->table_prog);
    if($nb !==NULL || $debut !== NULL){
    $q->LIMIT($nb, $debut);}

    if ($chaine_id !== NULL) {
        $q->where('channel_id', $chaine_id);
         $q->join($this->table_emission, 'programs.id=emissions.id');

                  return $q ->get()
                            ->result();
    } else {
        return $q->get()
                  ->result();

    }


}

这是我的桌子:

  • 程序(id,title,emission_id ...)
  • 排放(id,....,channel_id) 类别(id,...)
  • rel_emission_categories(category_id,emission_id)

我该怎么做?

4

1 回答 1

0

您没有指定,但这看起来像是使用 CodeIgniter 框架的 PHP。如果是这样,请修改以下内容以满足您的需要。

$query="SELECT *
FROM table1 INNER JOIN table2 on table1.col=table2.col
WHERE table1.whatever=? AND table1.hello=?
LIMIT 1";
$params=array();
$params[]='whatever';
$params[]='world';


$result=$this->db->query($query,$params);
$result=$result->result_array();
print_r($result);
于 2013-03-21T23:09:12.087 回答