Permalink
Browse files

Update plan

  • Loading branch information...
c9s committed Mar 12, 2012
1 parent dfceb8f commit 22a27f47039cd6cd802c7ce51984b19f8db4d36e
Showing with 45 additions and 8 deletions.
  1. +45 −8 Plan.md
View
53 Plan.md
@@ -170,11 +170,38 @@ Has many Relation:
$father->children[] = array( ... ); // append one book with current author_id
+ /*
+
+ find "children" relationship
+
+ found hasMany relationship
+
+ hasMany "child".
+
+ find hasMany foreight key (fathor_id)
+
+ create nwe child with current fathor_id
+
+ */
+
search
$father->children->where()
->like( 'name' , '%Bill%' );
+ /*
+
+ find "children" relationship
+
+ found hasMany relationship
+
+ hasMany "child".
+
+ find hasMany foreight key (fathor_id)
+
+ select children with where child.fathor_id = self.id
+
+ */
Many to many relation:
@@ -183,15 +210,21 @@ Many to many relation:
$author->books[] = array( 'title' => 'New book' );
-/*
- find "books" relation
- found many to many relationship:(author => author_books => books)
+ /*
+ find "books" relation
+
+ found many to many relationship:(author => author_books => books)
+
+ find target model (book)
- create new book
- book.id belongs to author_books.book_id
- author_books.author_id belongs to author.id
- create author_book link with (author_id, book_id)
-*/
+ create new book
+
+ the "books" is related to "author_books" (book.id belongs to author_books.book_id)
+
+ author_books.author_id belongs to author.id
+
+ create author_book link with (author_id, book_id)
+ */
list:
@@ -200,6 +233,10 @@ Many to many relation:
}
+ find:
+
+ $author->books->find( 123 ); // find 123 in a subset of author books
+
ManyToMany relation implementation:
tell schema, `AuthorBook.author_id` is linking to `self.id`

0 comments on commit 22a27f4

Please sign in to comment.