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.
General
find_one_by // Warning
brezelfelder
January 2015
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
Harro
January 2015
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...
brezelfelder
January 2015
Both ways are possible ...
->
http://fuelphp.com/docs/classes/model_crud/methods.html
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
brezelfelder
January 2015
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
brezelfelder
January 2015
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
Harro
January 2015
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"?
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,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
brezelfelder
January 2015
Harro
January 2015