-
Notifications
You must be signed in to change notification settings - Fork 35
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
Table Relationships #6
Comments
@brandonwamboldt What about adding the following method to the public function join($table, $one, $two, $type = 'join', $operator = '=') {
$this->joins[] = compact('table', 'one', 'two', 'type', 'operator');
} The method could then be used like (real world example): $popular_posts = Post::query()
->limit(3 - count($hero_posts))
->offset(0)
->join('postmeta', 'postmeta.post_id', 'post.ID')
->where_not_in(BasePost::get_primary_key(), $exclude)
->where_in(BasePost::get_primary_key(), $sticky_posts)
->where('postmeta.meta_key', 'turnstile_post_views_count')
->where_gte('post_date', date("F jS, Y", strtotime("-7 days")))
->sort_by('postmeta.meta_value')
->order('DESC')
->find(); |
@josegonzalez That's what I'm planning on doing, I've just been gathering a bunch of examples of things I do manually that I'd want this to be flexible enough to handle 😄 |
@brandonwamboldt did you make any progress on this? thanks |
Any updates on this issue? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All the examples are related to a simple table. What about tables with relationships.
E.g. An Organisation has many employees: So when I create a Organisation object at design time I will also have a array of employee set in the organisation object. Thus composing the employee object with the organisation object.
After doing that if I save organisation can i be assured that I will have a record in the organisation table and 1 or many employees in the employee table and their foreign keys set.
Please let me know.
The text was updated successfully, but these errors were encountered: