Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query->related() calls #197

Closed
awright022 opened this issue Jan 4, 2013 · 1 comment
Closed

query->related() calls #197

awright022 opened this issue Jan 4, 2013 · 1 comment

Comments

@awright022
Copy link

Originally posted on the Fuel forums(http://fuelphp.com/forums/discussion/11719/query-related-calls#Item_1):

In the documentation (http://fuelphp.com/docs/packages/orm/crud.html) there is a broken sample call:

Model_Article::query()->related('author', array('where' => array('active', '=', 1)));

This produces the following error: ErrorException [ 4096 ]: Argument 1 passed to Orm\Query::_parse_where_array() must be an array, string given, called in /fuel/packages/orm/classes/query.php on line 478 and defined

This is a sample that was found to work:
$query->related('author', array('where' => array('active' => 1)));

Options for fixing per Harro:

"As things stand at the moment, it's a typo, and the code expects your second example.

But in my opinion this is incorrect, as that syntax doesn't allow you to insert a where clause other then "is equal". Which means the code needs to be adapted to accept what is documented."

@WanWizard
Copy link
Member

This turned out to be a typo in the docs.

As you can define multiple where clauses, you have to put the clause(s) in an array:

Model_Article::query()->related('author', array('where' => array(array('active', '=', 1), array('status', '=', 'A'))))->get();

I'll update the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants