Cakephp中的UNIOn语法

Cakephp中的UNIOn语法,第1张

Cakephp中的UNIOn语法

太多的编码人员试图将自己局限于框架功能。别。使用框架提供的内容。如果它不具有您想要的功能,则可以:

  • 将所需的功能编码到类扩展中

要么

  • 在框架内自定义代码以适应您的需求。

通常,开发人员试图将一个方形钉锤入一个圆孔中,然后进行过多的额外工作,这实际上只会使代码变得复杂。退后一步,问一问为什么要使用该框架。它使结构成为一种非结构化的语言。它为构建您的应用程序提供了坚实的可重用基础。并不是要成为一个让自己陷入困境的盒子。

更新:我花了一点时间阅读“ 复杂查找条件”并找到了答案:

$joins = array(    array(        'table' => 'test_twos',        'alias' => 'TestTwo',        'type' => 'LEFT',        'conditions' => array( 'TestTwo.id = TestOne.id',        )    ),    array(        'table' => 'test_threes',        'alias' => 'TestThree',        'type' => 'LEFT',        'conditions' => array(        'TestThree.id = TestOne.id',    )    ));$dbo = $this->getDataSource();$subQuery = $dbo->buildStatement(    array(        'fields' => array('*'),        'table' => $dbo->fullTableName($this),        'alias' => 'TestOne',        'limit' => null,        'offset' => null,        'joins' => $joins,        'conditions' => null,        'order' => null,        'group' => null    ),    $this->TestOne);$query = $subQuery;$query .= ' UNIOn ';$joins = array(    array(        'table' => 'test_twos',        'alias' => 'TestTwo',        'type' => 'LEFT',        'conditions' => array( 'TestTwo.id = TestOne.id',        )    ),    array(        'table' => 'test_threes',        'alias' => 'TestThree',        'type' => 'RIGHT',        'conditions' => array(        'TestThree.id = TestOne.id',        )    ));$dbo = $this->getDataSource();$subQuery = $dbo->buildStatement(    array(    'fields' => array('*'),    'table' => $dbo->fullTableName($this),    'alias' => 'TestOne',    'limit' => null,    'offset' => null,    'joins' => $joins,    'conditions' => null,    'order' => null,    'group' => null    ),    $this->TestOne);$query .= $subQuery;pr($query);


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5043992.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存