Something About Findbyattributes

I have a table named user like below:




id || email

---------------------------------

1  || someone@foo.bar

---------------------------------

2  || 1manwithblueshirt@bar.foo

---------------------------------



When I search:





$userId = 2;

User::model()->findByAttributes(array('email' => $userId))->email;




result of the search is: 1manwithblueshirt@bar.foo

"Because MySQL decides to convert the email to an integer. The rules are to convert leading characters to a number, until the characters are not valid numbers."

I think the SQL code generating by findByAttributes should change from


SELECT * FROM user WHERE email = 1

To


SELECT * FROM user WHERE email = '1'

this is a problem of php where (1 == ‘1’) evaluates to true.