Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM find, find_by or query()->where get's me unwanted result
  • 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();




  • 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 ...
  • 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

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion