我在构造函数上有几个变量。如何将它们传递给另一个函数? 所以我不需要再写一遍了。 这是我的代码:
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;
}