Guest User

Untitled

a guest
Mar 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. class ArticlesTable extends Table
  2. {
  3. public function initialize(array $config)
  4. {
  5. parent::initialize($config);
  6. $this->hasMany('ArticlesTags', [
  7. 'dependent' => true,
  8. 'cascadeCallbacks' => false,
  9. 'propertyName' => 'article_tags'
  10. ]);
  11. }
  12. }
  13.  
  14. class ArticlesTagsTable extends Table
  15. {
  16. public function initialize(array $config)
  17. {
  18. parent::initialize($config);
  19. $this->belongsToMany('Articles')
  20. ->setForeignKey('article_id');
  21. /** I need ideas on how to associate with ArticlesTagNamesTable **/
  22. }
  23. }
  24.  
  25. class ArticlesTagNamesTable extends Table
  26. {
  27. public function initialize(array $config)
  28. {
  29. parent::initialize($config);
  30. /** I need ideas on how to associate with ArticlesTagsTable **/
  31. }
  32. }
  33.  
  34. [
  35. [
  36. 'id' => 145,
  37. 'article_body' => This is my first article body,
  38. 'article_author_id' => 13,
  39. 'article_date' => March 18 2017 19:00:12,
  40. 'article_tags' => [
  41. [
  42. 'id' => 3,
  43. 'article_id' => 145,
  44. 'article_tag_id' => 32,
  45. 'article_tag_name' => cakephp
  46. ],
  47. [
  48. 'id' => 4,
  49. 'article_id' => 145,
  50. 'article_tag_id' => 33,
  51. 'article_tag_name' => java
  52. ]
  53. ]
  54. ],
  55. [
  56. 'id' => 146,
  57. 'article_body' => This is my second article body,
  58. 'article_author_id' => 13,
  59. 'article_date' => March 18 2017 22:00:16,
  60. 'article_tags' => [
  61. [
  62. 'id' => 5,
  63. 'article_id' => 146,
  64. 'article_tag_id' => 34,
  65. 'article_tag_name' => php
  66. ]
  67. ]
  68. ]
  69. ]
  70.  
  71. [
  72. [
  73. 'id' => 145,
  74. 'article_body' => This is my first article body,
  75. 'article_author_id' => 13,
  76. 'article_date' => March 18 2017 19:00:12,
  77. 'article_tags' => [
  78. [
  79. 'id' => 3,
  80. 'article_id' => 145,
  81. 'article_tag_id' => 32,
  82. 'articles_tag_names' => [
  83. 'id' => 12
  84. 'article_tag_name' => cakephp
  85. ]
  86. ],
  87. [
  88. 'id' => 4,
  89. 'article_id' => 145,
  90. 'article_tag_id' => 33,
  91. 'articles_tag_names' => [
  92. 'id' => 13
  93. 'article_tag_name' => java
  94. ]
  95. ]
  96. ]
  97. ],
  98. [
  99. 'id' => 146,
  100. 'article_body' => This is my second article body,
  101. 'article_author_id' => 13,
  102. 'article_date' => March 18 2017 22:00:16,
  103. 'article_tags' => [
  104. [
  105. 'id' => 5,
  106. 'article_id' => 146,
  107. 'article_tag_id' => 34,
  108. 'articles_tag_names' => [
  109. 'id' => 14
  110. 'article_tag_name' => php
  111. ]
  112. ]
  113. ]
  114. ]
  115. ]
Add Comment
Please, Sign In to add comment