cakephp 3.x 2.x 的模型适配器
cakephp 3.x Model adapter for 2.x
有什么地方吗an adapter for cakephp 3.x model to handle 2.x syntax?就像,在内部,它只是像这样转换语法:
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)
和 return 执行了查询 ->toArray()。因此 2.x 的模型与 3.x.
兼容
非常感谢任何建议。
以防其他人遇到同样的问题:shim plugin can solve most of issues with compatibility 2.x and 3.x version。
在蛋糕 3 中,您不仅限于查询生成器,还可以将数组传递给 find()
(类似于 2.x 中的工作方式):
$query = $articles->find('all', [
'conditions' => ['Articles.created >' => new DateTime('-10 days')],
'contain' => ['Authors', 'Comments'],
'limit' => 10
]);
你可以看看它here
有什么地方吗an adapter for cakephp 3.x model to handle 2.x syntax?就像,在内部,它只是像这样转换语法:
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)
和 return 执行了查询 ->toArray()。因此 2.x 的模型与 3.x.
兼容非常感谢任何建议。
以防其他人遇到同样的问题:shim plugin can solve most of issues with compatibility 2.x and 3.x version。
在蛋糕 3 中,您不仅限于查询生成器,还可以将数组传递给 find()
(类似于 2.x 中的工作方式):
$query = $articles->find('all', [
'conditions' => ['Articles.created >' => new DateTime('-10 days')],
'contain' => ['Authors', 'Comments'],
'limit' => 10
]);
你可以看看它here