如何将每个变量传递给模型Codeigniter上的每个函数?

时间:2016-11-23 08:15:14

标签: php codeigniter

我在构造函数上有几个变量。如何将它们传递给另一个函数? 所以我不需要再写一遍了。 这是我的代码:

class Validasi_model extends CI_Model {

    public $tabelmhs;

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

$tabelmaster = $this->input->post('tabelmaster');

$query = $this->db->query("SELECT * FROM master_tabel where id_master_tabel = '$tabelmaster'");
$result = $query->result();

foreach ($result as $row){
    $tabelmhs = $row->nm_tabel_mahasiswa;
//i have lot variable here
}
}

我想将$ tabelmhs传递给另一个函数,依此类推

public function validasi_duplikat()
    {
$duplikat = $this->db->query("SELECT * FROM $tabelmhs WHERE nipd IN (
 SELECT nipd FROM $datamhs GROUP BY nipd HAVING count(*) > 1) ");
 return $duplikat;
        }

0 个答案:

没有答案