我如何在codeigniter中执行此操作

时间:2014-07-24 17:44:32

标签: php mysql codeigniter

我想获得此功能id

function load_gig()
{
    $query = $this->db->query("SELECT * FROM gigs ORDER BY id DESC");

    if ($query->num_rows() > 0)
    {
        return $query->result_array();
    }
}

然后把它放在这里

function load_game_gig()
    {
        $query = $this->db->query("SELECT * FROM gigs WHERE id= ");

        if ($query->num_rows() > 0)
        {
            return $query->result_array();
        }
    }

然后在视图中显示它

1 个答案:

答案 0 :(得分:0)

假设您上面描述的功能是模型功能:

function load_game_gig($id)
    {
        $query = $this->db->query("SELECT * FROM gigs WHERE id= '.$id.'");

        if ($query->num_rows() > 0)
        {
            return $query->first_row('array');
        }
    }

然后在控制器中:

$data = $this->model->load_gig();


$this->model->load_game_gig($data['id']);