【问题标题】:CakePHP recursive 2 with translate behavior具有翻译行为的 CakePHP 递归 2
【发布时间】:2013-04-17 17:59:14
【问题描述】:

我想通过代码查找所有关系:

$this->set('types', $this->Project->ProjectType->find('all', array(
    'recursive' => 2)));

当我将递归设置为 2 时出现错误:

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'I18n__name.content' in 'field list'

模型ProjectType 使用content 字段(文本类型)的翻译行为。 其他递归效果很好。 recursive = 2如何返回结果?

【问题讨论】:

    标签: cakephp recursion internationalization cakephp-2.3


    【解决方案1】:

    根本不要使用递归。

    在您的 AppModel 中将其设置为 public $recursive = -1;,之后不要更改它。然后使用CakePHP's Containable Behavior 检索关联数据。

    递归会给你带来比它更令人头疼的问题。如果 Containable 不是那么容易/真棒,也许我们会被递归使用,但是......它很棒而且很容易:)

    【讨论】:

    • 好吧,我稍后会检查这种行为,但我的问题出在哪里?因为我使用翻译行为?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-09
    • 2020-07-09
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    相关资源
    最近更新 更多