fuck’n Cake

  • このエントリーをはてなブックマークに追加
  • Pocket

CakePHP3を触っててムカついたのでメモ。

どなたか、tebleのinitializeで3つのテーブルを結合する方法を教えて頂きたい。。。  

cakeが嫌い

cake中の人は表結合って2テーブルでしかしないと思ってるのかな?
SQL書いたほうが簡単で早いってのはどうゆうことだろうね。

どなたか、tebleのinitializeで3つのテーブルを結合する方法を教えて頂きたい。。。  

hogeテーブルに対して

これはできる:foo -> hoge <- bar
これができない:hoge -> foo -> bar  

cake3はrecursive消したようだし、contain使ってねというわりには そこらの説明もないし…

以下、cakephp3 Cookbook からの引用。

Recursive and ContainableBehavior Removed

In previous versions of CakePHP you needed to use recursive, bindModel(), unbindModel() and ContainableBehavior to reduce the loaded data to the set of associations you were interested in. A common tactic to manage associations was to set recursive to -1 and use Containable to manage all associations. In CakePHP 3.0 ContainableBehavior, recursive, bindModel, and unbindModel have all been removed. Instead the contain()method has been promoted to be a core feature of the query builder. Associations are only loaded if they are explicitly turned on. For example:

$query = $this->Articles->find(‘all’);

Will only load data from the articles table as no associations have been included. To load articles and their related authors you would do:

$query = $this->Articles->find(‘all’)->contain([‘Authors’]);

By only loading associated data that has been specifically requested you spend less time fighting the ORM trying to get only the data you want.

どういうことだってばよ?

  • このエントリーをはてなブックマークに追加
  • Pocket

SNSでもご購読できます。

コメントを残す

*