Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
find_one_by // Warning
  • Heu, 

    i have a strange warning. 

    I try to get one Tabel element by using "find_one_by".

    $entry = Model_Article_Illustration::find_one_by('article_id', $id);
    ($id is simple number )

    What i get is this warning:


    Fuel\Core\PhpErrorException [ Warning ]:
    array_key_exists() expects parameter 2 to be array, string given


    do you have any idea ? 
    Thanks Ralf


  • I never use this notation, but I think your syntax is wrong:

    $entry = Model_Article_Illustration::find_one_by_article_id($id);

    I think the fieldname is part of the method name...
  • Both ways are possible  ...

    But I have errors with both methods.
    With your method I get another Error. Here it says, that $entry is no default Object.

    Thanks so far,
    Ralf
  • Sorry, I get this error when I'm using "find_one_by_article_id($id)"
    Fuel\Core\PhpErrorException [ Notice ]:
    Trying to get property of non-object

    But there is one entry in the database .... 
    it is really strang. I have a "_has_one" relation between a model called "Article" has_one  "illustration".
    but I can't add the Model to the $article object ....

    $article = Model_Article::find($id);
    $article->illustration = Model_Article_Illustration::find_one_by_article_id($id);

    any ideas what's going wrong here ? 

    Thanks,
    Ralf




  • So I did some test.

    each time is use "find_one_by()" or "find_one_by_article_id()"  I get nothing. 
    Is there any other way to get a object (not a array) from the Database ? 

    Thanks,
    Ralf
  • I have to look into the code to see how this exactly works, as I said I never use this.

    find_by_article_id($id) works here btw, and returns a single object.

    So perhaps it is the "by_one" that is not supported, but only "find_by" and "find_all_by"?

Howdy, Stranger!

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

In this Discussion