Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Array given with find_one_by
  • Hello, little problem here:

    I tried using "find_one_by" to get a userentry from my database. In the documentation stand:

    $column string required
    $value mixed

    So i tried using the following:

    $userrightselected = Model_Userright::find_one_by('userID', Input::Post('user'));

    To get a form-value from a previouse selection. But i get a warning:

    array_key_exists() expects parameter 2 to be array, string given

    if ( ! array_key_exists('where'$options))
    715            {
    716                $options['where'] = $where;
    717            }

    But the documentation says that its mixed. So do i have to use an array now or did i do something wrong? 
  • By the way: yes, i do want the script to throw the warnings out, just because i want the script to work as well as it can get.
  • You're using it wrong.

    $userrightselected = Model_Userright::find_one_by_userID(Input::Post('user'));

    The second argument is an options array, just like with the standard find() call.
  • Well, then it might help to change the documentation for the function, because:

    Model_User::find_one_by('email', 'info@example.com');

    is a little bit misunderstandable. The same goes for the headline:


    Maybe change the function-description in the way like "find_one_by_{column}($value = null, $operator = '=') would be better to understand.

    But thanks, it works now.
  • Yup, that is clearly not correct. More docs work. ;-)

    I'll add it to the todo list.

Howdy, Stranger!

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

In this Discussion