I'm creating a database this way:
$db=new PDO('mysql:host='.$db_host.';dbname='.$db_name.';charset=utf8',$db_user,$db_pass,array(
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
and at some point I want to insert a string in a table containing strange characters, using prepared statements. for example
$title='vélo';
$db->prepare('INSERT into table (title) VALUES(:title)');
$db->execute(array('title' => $title));
This causes me the string to be stored as vélo
, even though the whole database,table and entries are encoded as utf8_general_ci.
1)Could I avoid this transformation?
2)If not, how could I then do a case-insensitive search in my database? using
SELECT * FROM table WHERE title LIKE '%velo%'
does not give me any results...