• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
jQuery UI Livesearch works with English, but don't work with Cyrillic characters

#1
Hello, I have a problem with jQuery UI Livesearch - it works perfect with English but do not work with Cyrillic - empty array and I have both in my database. I am using CI 3.1.5 and Firebird 1.5. When I using MySql (with like query) table is with charset utf-8 and Collation-utf8_general_ci I have the same problem - English works, Cyrillic don't. Here is my code:

My Model:
PHP Code:
public function get_autocomplete($search_data)



$data mb_convert_encoding($search_data"Windows-1251""UTF-8");

// var_dump($data);

$query $this->db1->query("select cl.name
from clients cl
where (cl.name containing  '
$search_data')"); 

//var_dump($query);

return $query->result();



My controller:

PHP Code:
<?php
 
class search extends CI_Controller{

public function 
index()
{
$search_data $this->input->get("input_data");

$results  $this->search_model->get_autocomplete($search_data);

if(!empty( 
$results))
{

$jsonData = array(); //Create array  
            foreach( $results as $row  
            
 
                $jsonData
[] = array(   
                                     
'value' => $row->NAME
                                     
);   
            
 
           $this
->output->set_header("Access-Control-Allow-Origin: *, Content-type: application/json, charset=windows-1251");

echo 
json_encode($jsonData);
}
}

My Ajax:

PHP Code:
$(".addClient").each(function() { 
   
$(this).autocomplete({
  autoFocustrue,
   minLength2  
   source
: function (requestresponse) {
       $.ajax({
           url "<?php echo  site_url('search');?>",
           scriptCharset"windows-1251",
           data : { 'input_data' request.term},
           contentType"application/json; charset=windows-1251",
           dataType"json",
           success: function (data){
            var result = [];
            data.forEach(function (valueindex) {
       result.push({label:value.valuedata:value });
   });
 
   response
(result);
}
      });
   }, 
});
  }); 

Edit

I tried with php without CI and it works. So I must change some CI settings.

My database settings:

PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
 
   'dsn'   => '',
 
   'hostname' => 'localhost',
 
   'username' => 'root',
 
   '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'//same result with NONE
 
       'dbcollat' => 'PXW_CYRL'//same result with ''
 
       'swap_pre' => '',
 
       'encrypt' => FALSE,
 
       'compress' => FALSE,
 
       'stricton' => FALSE,
 
       'failover' => array(),
 
       'save_queries' => TRUE
    
); 




I tried mb_convert_encoding, iconv, change charset and nothing. The field in the database is win1251. 
What I am doing wrong?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.