【问题标题】:Why addCondition between two expression fields does not work?为什么两个表达式字段之间的 addCondition 不起作用?
【发布时间】:2012-06-16 17:48:58
【问题描述】:

我正在构建一个模型来列出当月过生日的学生: 但这不会返回任何记录,尽管有一些确实匹配,但这不是根据来自 addExpression 的两个字段添加条件的正确方法吗? 正确的方法是什么?

class Model_Student_ThisMonthBirthday extends Model_Student {
  function init(){
    parent::init();

    $this->addExpression('birthdayMonth')->set("month(birthDate)");
    $this->addExpression('currentMonth')->set("month(now())");

    $this->addCondition('birthdayMonth','currentMonth');
  }
}

【问题讨论】:

  • 我使用 php 函数解决了我的问题:date("n") insted of 'currentMonth'

标签: php user-interface frameworks atk4


【解决方案1】:

第二个参数默认是一个值,所以如果你想在那里使用字段,你应该这样做:

$this->addCondition('birthdayMonth', $this->getElement('currentMonth'));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 2014-02-04
    • 2013-12-05
    相关资源
    最近更新 更多