简体   繁体   English

来自MYSQL的值将为空

[英]Value from MYSQL is coming null

I am fetching code from codeignitor using implode function. 我正在使用爆破功能从Codeignitor中获取代码。 here is the code 这是代码

$this->load->database();
        $session_data = $this->session->userdata('logged_in');
        $user_id = $session_data['user_id'];

        $this->db->select('skill_id');
        $this->db->from('user_info_skillset');
        $this->db->where('user_id',$user_id);
        $query = $this->db->get();
        foreach($query->result() as $row)
        {
            $skill_id[] = $row->skill_id;
        }

        $test = implode(',',$skill_id);

//        echo '<pre />';
//                print_r($test); exit;
        $this->db->select('project_id');
        $this->db->from('project');
        $this->db->where_in('required_skills',$test);
        $query1 = $this->db->get();

        echo '<pre />';
                print_r($query1); exit;
        return $query1->result();

The problem is i can not able to fetch data for 问题是我无法获取数据

  echo '<pre />';
                print_r($query1); exit;
        return $query1->result();

When i try enter this database query manually in mysql workbench it is working, but by code it displays null value. 当我尝试在mysql工作台中手动输入此数据库查询时,它正在工作,但是通过代码显示空值。 is that anything missing in code? 代码中缺少什么吗? please guide me. 请指导我。 below is my output. 以下是我的输出。

Output 产量

CI_DB_mysql_result Object
(
    [conn_id] => Resource id #34
    [result_id] => Resource id #38
    [result_array] => Array
        (
        )

    [result_object] => Array
        (
        )

    [custom_result_object] => Array
        (
        )

    [current_row] => 0
    [num_rows] => 0
    [row_data] => 
)

You should use the FIND_IN_SET clause in your query: 您应该在查询中使用FIND_IN_SET子句:

$test = implode(',',$skill_id);
$where  = " FIND_IN_SET(required_skills,'".$test."') ";
$this->db->select('project_id');
$this->db->from('project');
$this->db->where( $where, false );
//$this->db->where_in('required_skills',$test);
$query1 = $this->db->get();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM