Querying in mysql with php does not return result in queries with accents

1

Hello, I have a system in php / mysql using zend 1.12, but when I query the mysql database with a word that does not have an accent and the table has an accent, it does not return any results, for example:

When searching: {joao} and in the database this {joão}, does not return results.

The database is configured with: InnoDB latin1_general_ci.

I want to know if I have to remove the accents of the records that are already in the table for the query to occur naturally when the user searches for words without an accent.

ex: user type: {atencao} in the table I have the phrase: {Be very careful to pay attention when returning from the trip.}

this returns 0 result.

I do not know if I could be clear, I already tried the forum here and found nothing similar.

If someone can indicate a link or give some tips or even clarify this.

Thank you.

    
asked by anonymous 10.04.2015 / 22:02

1 answer

2

You can perform the query without it accentuating the following:

SELECT *
FROM minhaTabela
WHERE minhaColuna LIKE '%joao%' COLLATE utf8_general_ci

Considerations

Alternative

You can resolve the issue faster if you edit the table in the database and change the collation of the column where you are performing the search to UTF-8 , specifically utf8_unicode_ci , thus ensuring that the accented letters will be identified in its version with or without accent.

Zend 1.12

To perform the query using the object Zend_Db_Select via fluent interface :

$select = $db->select()
    ->from( "minhaTabela", "*" )
    ->where( "minhaColuna LIKE '%joao%' COLLATE utf8_general_ci" );
    
11.04.2015 / 02:48