2016-11-26 9 views
0

2.x syntaxを処理するcakephp 3.xモデルのために、どこかにan adapterがありますか?cakephp 3.x 2.x用モデルアダプター

array(
    'conditions' => array('Model.field' => $thisValue), 
    'fields' => array('Model.field1', 'DISTINCT Model.field2'), 
    'order' => array('Model.created', 'Model.field3 DESC'), 
    'group' => array('Model.field'), 
    'limit' => n 
) 

へ:同様に、内部的に、それはちょうどこのような構文を変換

$query->select('Model.field1') 
->distinct('Model.field2') 
->order->(['Model.created', 'Model.field3' => 'DESC']) 
->group('Model.field') 
->where('Model.field' => $thisValue) 

をし、実行されたクエリを返す - >のtoArray()。したがって、2.xのモデルは3.xと互換性があります。

アドバイスをいただきありがとうございます。

+0

可能性のあるオフサイトのリソースを尋ねる質問は、StackOverflowでの議論とみなされます。あなたは[** CakePHPフォーラム**](http://discourse.cakephp.org/)または[** IRC **](http://webchat.freenode.net/)でそのような質問をする方がよいでしょう。 ?channels = cakephp)/ [** Slack **](http://cakesf.herokuapp.com/)。 SOは、構文Aから構文Bへの変換に関連するプログラミング関連の問題を尋ねる場所です。 – ndm

+0

ありがとう、ありがとう。 [there](http://discourse.cakephp.org/t/compatibility-adapter-for-model-2-x-to-becomes-compatible-with-3-x-orm/1616)にも尋ねられました – Alex

答えて

0

、あなたも(それは2.xの中で働いていた方法に類似)find()に配列を渡すことができます。

$query = $articles->find('all', [ 
    'conditions' => ['Articles.created >' => new DateTime('-10 days')], 
    'contain' => ['Authors', 'Comments'], 
    'limit' => 10 
]); 

あなたは

hereそれについてを読むことができます
+0

ありがとう、 非常に役立ちます。なぜ私はそれを逃したのか分からない... – Alex

0

同じ問題に直面している他の人の場合:shimプラグインを使用すると、ほとんどの問題をcompatibility 2.x and 3.x versionで解決できます。あなたは、ビルダーを照会するために限定されるものではないケーキ3では

関連する問題