I am working on live search with jQuery UI autocomplete and CI 3.1.5. It works fine with MySQL, but with Firebird 1.5 I have an empty array. The problem is in my like query.
Here is my code:
public function get_autocomplete($search_data)
{
$this->db1->select('NAME');
$this->db1->like('NAME', $search_data);
return $this->db1->get('CLIENTS', 10)->result();
}
I also tried this:
public function get_autocomplete($search_data)
{
$query = $this->db1->query("select cl.name
from clients cl
where cl.name like '%$search_data%'");
return $query->result();
}
The result is again, an empty array. If I don't use LIKE, my query returns 10 results fine. What am I doing wrong?
Edit:
Firebird 1.5 works with containing. This code works with English:
$query = $this->db1->query("select cl.name
from clients cl
where (cl.name containing '$search_data')");
I just tried with MySQL (with like query) table is with charset utf-8 and Collation-utf8_general_ci and I have the same problem - English works, Cyrillic don't. I just tried with pure php and it works in English and Cyrillic. So the problem is in Codeigniter settings?
Here is my database configurations:
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '*****',
'username' => '****',
'password' => '',
'database' => 'bulvestprint_mysql',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['firebird'] = array(
'dsn' => '',
'hostname' => 'LOCALHOST',
'username' => '******',
'password' => '******',
'database' => 'D:\Firebird_1_5\BULVEST_SPAS.GDB',
'dbdriver' => 'ibase',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'WIN1251', //беше NONE
'dbcollat' => 'PXW_CYRL', //беше празно
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I tried changing char_set and collation also changed $config['charset'] = 'UTF-8'; with windows-1251 and nothing.
Thank you for your time. What am I doing wrong?
I found the problem. The problem with MySQL was this line:
Now it works:
The problem with Firebird with Cyrillic search is caused by the database charset 'NONE'.