Yii Framework Forum: Something About Findbyattributes - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Something About Findbyattributes Rate Topic: ***-- 1 Votes

#1 User is offline   raminious 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 27-June 10
  • Location:tehran

Posted 06 February 2013 - 07:21 PM

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'

coding is my life, i love my life
0

#2 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 535
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 06 February 2013 - 08:47 PM

this is a problem of php where (1 == '1') evaluates to true.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users