我的sql查询正在破解并抛出
致命错误:未捕获错误:调用成员函数result_array() on boolean。
我怎样才能逃脱单引号。 这是我的模特。
function get_ftth_team_by_name($team_name){
$sql = "SELECT
*
FROM
ct_ftth_teams
WHERE
ct_ftth_teams.team_name = '$team_name'";
$result = $this->db->query($sql);
$data = array();
foreach ($result->result_array() as $row) {
$data[] = $row;
}
return $data;
}
这是我的控制器。
function add_ftth_team($msg = null)
{
if (isset($_POST['add_team'])) {
$data['team_name'] = $_POST['team_name'];
$data['team_leader'] = preg_replace('/\s+/', ' ', $_POST['leader_id']);
$data['team_member'] = $_POST['team_members'];
$data['description'] = $_POST['description'];
$get_teams = $this->staff_activity_model->get_ftth_team_by_name($data['team_name']);
if ($get_teams) {
redirect('staff_activity/add_ftth_team/error');
} else {
$this->staff_activity_model->add_ftth_team($data);
redirect('staff_activity/view_teams');
}
}
$this->data['main_template'] = 'staff_activity/staff_activity_main';
$this->data['inner_template'] = 'staff_activity/ftth/staff_activity_ftth_add_team';
$this->data['inner_nav'] = 'staff_activity/staff_activity_nav';
$this->load->view('common/common', $this->data);
}