Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ArticlesTable extends Table
- {
- public function initialize(array $config)
- {
- parent::initialize($config);
- $this->hasMany('ArticlesTags', [
- 'dependent' => true,
- 'cascadeCallbacks' => false,
- 'propertyName' => 'article_tags'
- ]);
- }
- }
- class ArticlesTagsTable extends Table
- {
- public function initialize(array $config)
- {
- parent::initialize($config);
- $this->belongsToMany('Articles')
- ->setForeignKey('article_id');
- /** I need ideas on how to associate with ArticlesTagNamesTable **/
- }
- }
- class ArticlesTagNamesTable extends Table
- {
- public function initialize(array $config)
- {
- parent::initialize($config);
- /** I need ideas on how to associate with ArticlesTagsTable **/
- }
- }
- [
- [
- 'id' => 145,
- 'article_body' => This is my first article body,
- 'article_author_id' => 13,
- 'article_date' => March 18 2017 19:00:12,
- 'article_tags' => [
- [
- 'id' => 3,
- 'article_id' => 145,
- 'article_tag_id' => 32,
- 'article_tag_name' => cakephp
- ],
- [
- 'id' => 4,
- 'article_id' => 145,
- 'article_tag_id' => 33,
- 'article_tag_name' => java
- ]
- ]
- ],
- [
- 'id' => 146,
- 'article_body' => This is my second article body,
- 'article_author_id' => 13,
- 'article_date' => March 18 2017 22:00:16,
- 'article_tags' => [
- [
- 'id' => 5,
- 'article_id' => 146,
- 'article_tag_id' => 34,
- 'article_tag_name' => php
- ]
- ]
- ]
- ]
- [
- [
- 'id' => 145,
- 'article_body' => This is my first article body,
- 'article_author_id' => 13,
- 'article_date' => March 18 2017 19:00:12,
- 'article_tags' => [
- [
- 'id' => 3,
- 'article_id' => 145,
- 'article_tag_id' => 32,
- 'articles_tag_names' => [
- 'id' => 12
- 'article_tag_name' => cakephp
- ]
- ],
- [
- 'id' => 4,
- 'article_id' => 145,
- 'article_tag_id' => 33,
- 'articles_tag_names' => [
- 'id' => 13
- 'article_tag_name' => java
- ]
- ]
- ]
- ],
- [
- 'id' => 146,
- 'article_body' => This is my second article body,
- 'article_author_id' => 13,
- 'article_date' => March 18 2017 22:00:16,
- 'article_tags' => [
- [
- 'id' => 5,
- 'article_id' => 146,
- 'article_tag_id' => 34,
- 'articles_tag_names' => [
- 'id' => 14
- 'article_tag_name' => php
- ]
- ]
- ]
- ]
- ]
Add Comment
Please, Sign In to add comment