Model.php
// Declare $datetime_limit
public datetime_limit;
Controller.php
// datetime_limit should be the actual datetime + 5 days
$criteria->select="DATE_ADD(NOW(), INTERVAL 5 DAY) AS datetime_limit";
エラーメッセージ:
Active record "Users" is trying to select an invalid column "DATE_ADD(NOW()". Note, the column must exist in the table or be an expression with alias.
編集1:
リレーションテーブル(多対多)を使用して、条件付きの検索をフィルタリングしたいと思います。したがって、datetime_limit
リレーショナルで持つことはできませんevents.datetime
。どうやってやるの?
$criteria->select=array("DATE_ADD(NOW(), INTERVAL 5 DAY) AS datetime_limit");
$criteria->with=array('events');
$criteria->having='datetime_limit!=`events`.`datetime`';
$models=Users::model()->findAll($criteria);