1

今月中に誕生日を迎える学生を一覧表示するモデルを作成しています。ただし、実際に一致するものもありますが、これはレコードを返しません。これは、addExpressionからの2つのフィールドに基づいて条件を追加する正しい方法ではありません。 ?正しい方法は何ですか?

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');
  }
}
4

1 に答える 1

1

デフォルトでは2番目の引数は値であるため、そこでフィールドを使用する場合は、次のようにする必要があります。

$this->addCondition('birthdayMonth', $this->getElement('currentMonth'));
于 2012-06-17T08:03:55.273 に答える