Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Possible find_by_* bug?
  • I had a situation when find_by_* would not find and return row even if it matched value? Is this possible?
    I had this issue on this particular code:
    $user = Model_User::find_by_email($email);
    if($user)
    {
          Log::info('User exists');
    }
    else
    {
          Log::info('No user!');
    }
    
    I had a situation when user with searched email was already in the users table, but the if condition would end up in else part of the sentence... Is this possible in any situation?
  • Activate the profiler, and see which query has been generated for this find().
  • This is the query generated by above find_by_email
    SELECT `t0`.`old_id` AS `t0_c0`, `t0`.`profile_fields` AS `t0_c1`, `t0`.`id` AS `t0_c2`, `t0`.`username` 
    AS `t0_c3`, `t0`.`password` AS `t0_c4`, `t0`.`status` AS `t0_c5`, `t0`.`group` AS `t0_c6`, `t0`.`email` 
    AS `t0_c7`, `t0`.`last_login` AS `t0_c8`, `t0`.`login_hash` AS `t0_c9`, `t0`.`reset_hash` AS `t0_c10`, 
    `t0`.`remember_me` AS `t0_c11`, `t0`.`created_at` AS `t0_c12`, `t0`.`updated_at` AS `t0_c13` 
    FROM `users` AS `t0` WHERE (`t0`.`email` = 'primozrr@gmail.com') ORDER BY `t0`.`id` ASC 
    LIMIT 1
    
  • Can't see anything wrong with it, no obvious reasons why it would return the incorrect results.

Howdy, Stranger!

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

In this Discussion