检查值是否在数据库中-Codeigniter

时间:2018-12-11 06:01:21

标签: codeigniter codeigniter-3

public function search($uid = FALSE) {       
         $data['page_title'] = "Signature Uploader";

                if (!$uid) {
                    $this->load->helper('user');
                    $dd['employees'] = get_all_employees();
                    $data['page_content'] = $this->load->view('signature_uploader/search', $dd, TRUE);
                } else {
                    $this->load->database('employee');
                    $result = $this->db->query("SELECT uid FROM `signatures` WHERE  uid = '$this->uid'");    
                    $emp = $result->result_array();
                    $dd['agent'] = new Employee($uid);
                    var_dump($result);
                   if($uid==$emp){
                    $data['page_content'] = $this->load->view('signature_uploader/upload', $dd, TRUE);                
                   }else
                    redirect(base_url() . "signature_uploader/search");           
                }
                $this->load->view('signature_uploader/exv_page', $data);    
           }

嗨,我的代码遇到了麻烦,我是Codeigniter的新手。一点帮助将是伟大的家伙。我要这样做的是,当用户搜索员工时,它将首先使用signatures检查该员工是否已经在uid(primary key)表中。 signatures.uid = employee.uid。我在正确使用我的result_array()吗?

0 个答案:

没有答案