2009年12月22日星期二

Re: [fw-mvc] Problem: Turkish Characters can not be saved to database

Also you can pass the string into that function without any other replacement beforehand.

Sent from my iPhone

On 22 Dec 2009, at 12:43, Erdal YAZICIOGLU <erdal.yazicioglu@gmail.com> wrote:

Hello all

I have a really very strange problem withthe Turkish characters.

I have a form where alumni registers itself. I am trying to convert all
data to lowercase and then write to database.

In the model I create a function

public function toLowerCase($input)
{
return strtolower(strtr($input,'ĞÜŞIİÖÇ','ğüşıiöç'));
}

After a successful admission I write the data to database in model as
follows.

function registerAlumni($alumniName,$alumniLastName,$alumniGraduateDate)
{
$data = array('alumni_Name'=>$this->toLowerCase($alumniName),
'alumni_LastName'=>$this->toLowerCase($alumniLastName),
'alumni_GraduateDate'=>$alumniGraduateDate);
$this->insert($data);
}

Up to here everything seems to be OK. But when I run the database query,
the characters that are entered in turkish are not written into
database.

I really do not know, if it is Zend or Mysql itself. I use UTF-8 as
character encoding and if I do not use toLowerCase method, it writes to
database without problem.

Any ideas are more than welcome.

E

mysql> select alumni_Name,alumni_LastName,alumni_GraduateDate from
gbhl_alumni order by alumni_ID desc
-> ;
+---------------------+-----------------+---------------------+
| alumni_Name | alumni_LastName | alumni_GraduateDate |
+---------------------+-----------------+---------------------+
| | mmmmmmmmmmm | 1991 |
| | mmmmmmmmmmm | 1991 |
| | mmmmmmmmmmm | 1991 |
| | mmmmmmmmmmm | 1991 |
| | mmmmmmmmmmm | 1991 |
| | mmmmmmmmmmm | 1991 |
| | mmmmmmmmmmm | 1991 |
| mmmmmmmmmmmmmmmm | mmmmmmmmmmm | 1991 |
| | | 1991 |
| | | 1991 |

没有评论: