Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm
ORM find, find_by or query()->where get's me unwanted result
Jume
November 2015
Why does this always returns me the same product?
1. $product = \Model_Product::find(74);
2. $product = \Model_Product::find('74HC14');
In both cases I get out the product with ID=74. Shouldn't the second one return null?
Same goes if I use these two approaches:
$product = \Model_Product::find_by_id(74);
$product = \Model_Product::query()->where('id', '=', '74'))->get_one();
Jume
November 2015
OK this is MySQL thing...
SELECT * FROM `products` WHERE id = 12
and
SELECT * FROM `products` WHERE id = '12ABC'
gives the same result. This casting is done automatically by MySQL. I did not know this ...
Harro
November 2015
Because find() does a query on primary key (usually 'id'), which is a numeric column?
Both PHP and MySQL do implicit type conversions, for MySQL see
http://dev.mysql.com/doc/refman/5.7/en/type-conversion.html
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
November 2015
Jume
November 2015