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

Allow fully custom query #2

Merged
merged 2 commits into from
Feb 21, 2016
Merged

Allow fully custom query #2

merged 2 commits into from
Feb 21, 2016

Conversation

ext
Copy link
Member

@ext ext commented Feb 21, 2016

While rudimentary grouping and joining is possible with BasicObject::selection there are many cases where it just isn't possible to generate the needed SQL. For instance joining the table with itself needs table aliases which BO doesn't add. Grouping in general isn't BOs strong side but using a HAVING condition is just not possible.

This change allows for using a fully customized query (grouping, joining, etc) while still creating instances of your BO model similar to how BasicObject::selection does.

static public function myCustomSelection(){
  return static::selection_execute([
    'SELECT * FROM `my_table` ...'
  ]);
}

It assumes the user know what he is doing (i.e. not selecting all the required fields it considered a programming error by the caller).

ext and others added 2 commits February 21, 2016 16:07
This allows for using a fully customized query (grouping, joining, etc) while still creating instances of your BO model similar to how `selection` does.
torandi added a commit that referenced this pull request Feb 21, 2016
@torandi torandi merged commit f45147e into master Feb 21, 2016
@torandi torandi deleted the custom_query branch February 21, 2016 17:58
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

Successfully merging this pull request may close these issues.

2 participants