将数据从函数传递到ci3中的其他函数

问题描述 投票:0回答:1

我有2个这样的功能

class Infograph extends CI_Controller
{
    public function index()
    {
    $wilayah = $this->input->post('wilayah', TRUE);
        $kodeSubWilayah = $this->input->post('subWilayah', TRUE);

        if ($kodeSubWilayah) {
            $kodeSubWilayah = $this->encryption->decrypt($kodeSubWilayah);
            if ($kodeSubWilayah === false) {
                redirect('test/404');
            }
        }

        if ($wilayah) {

            $data['wilayah'] = strtolower($wilayah);
        }

        if ($kodeSubWilayah) {
            $data['subWilayah'] = $db2->query("SELECT * FROM provinsi WHERE id = ?", [$kodeSubWilayah])->result_array();
        } 
    }

    public function export()
    {
        // i want to send data $data['wilayah'] and $data['subWilayah']
    }

}

如何将数据传递到导出功能?我想获取 $data['wilayah'] 和 $data['subWilayah']

php codeigniter
1个回答
0
投票

使用函数参数

public function export($datawilayah,$datasubWilayah)

在索引函数中调用导出函数,如

$this->export($data['wilayah'],$data['subwilayah'])

© www.soinside.com 2019 - 2024. All rights reserved.