FIND_IN_SET () function does not work in codeigniter

The function FIND_IN_SET()works on the local, but does not work on the server. When I load company_by_category_modelby calling the controller (controller name) then it throws an error

Error:

FUNCTION firstdial.FIND_IN_SET does not exist

SELECT * FROM (`company_information`, `user_information`) 
WHERE `FIND_IN_SET` ('16',company_category) 
AND company_information.allowstatus=1 
AND company_information.delstatus=0 
AND company_information.user_id=user_information.user_id 
ORDER BY `company_id` desc

Filename: C:\wamp\www\firstdial\system\database\DB_driver.php
Line Number: 331

The code:

function company_by_category_model($category_id)
{   
    $this->db->select('*');
    $this->db->from('company_information,user_information');
    $search="FIND_IN_SET ('$category_id',company_category) 
        AND company_information.allowstatus=1 
        AND company_information.delstatus=0 
        AND company_information.user_id=user_information.user_id";
    $this->db->where($search);
    $this->db->order_by('company_id','desc');
    $query=$this->db->get();
    return $query->result();
}
+4
source share
3 answers

You should always check the results of the FIND_IN_SET () function to make it work, try the following:

  $this->db->where("FIND_IN_SET('$value',employer_job_location) !=", 0);
+2
source
function company_by_category_model($category_id)
{
    $this->db->select('*');
    $this->db->from('company_information,user_information');
    $search="FIND_IN_SET ('".$category_id."',company_category) 
        AND company_information.allowstatus=1 
        AND company_information.delstatus=0 
        AND company_information.user_id=user_information.user_id";
    $this->db->where($search);
    $this->db->order_by('company_id','desc');
    $query=$this->db->get();
    return $query->result();
}

Try removing the single quote from $category_id, this is a variable

+1
source

FIND_IN_SET() - This function is useful when you have a comma separated list of values ​​stored in the database and you want to check if a value exists in this comma separated list.

Example: WHERE FIND_IN_SET( ‘yellow, color list )

0
source

Source: https://habr.com/ru/post/1659919/


All Articles