我是CodeIgniter的新手。我现在创建了一个在 mysql db 表中插入记录的方法,如果同名的记录已经存在,则使查询停止,所以我写道:
public function set_project()
{
// If project name already exists?
$query = $this->db->query("SELECT pro_id FROM projects WHERE pro_name = '".$this->input->post('pro_name')."'");
if ( sizeof($query->row_array()) == 0) {
$data = array(
'is_featured' => $this->input->post('is_featured'),
'pro_type' => $this->input->post('pro_type'),
'pro_name' => $this->input->post('pro_name'),
'pro_client' => $this->input->post('pro_client'),
'pro_loc_city' => $this->input->post('pro_loc_city'),
'pro_loc_state' => $this->input->post('pro_loc_state'),
'pro_yr_start' => $this->input->post('pro_yr_start'),
'pro_yr_end' => $this->input->post('pro_yr_end'),
'pro_loc_cur' => $this->input->post('pro_loc_cur'),
'pro_size' => $this->input->post('pro_size'),
'pro_size_cat' => $this->input->post('pro_size_cat'),
'pro_size_units' => $this->input->post('pro_size_units'),
'pro_desc' => $this->input->post('pro_desc')
);
return $this->db->insert('projects', $data);
} else {
return "Already exists";
}
哪个工作正常,但我可以向谁显示我的视图?