この問題は、過去数時間私を夢中にさせてきました。属性posts_published_dateをユーザーエンティティに追加しました (特定のユーザーが最後に投稿した日付を追跡します)。関連する行を次に示します。
エンティティの属性を初期化しています。
/**
* @Column(type="integer", length=3, nullable=false)
*/
protected $posts_published_today;
/**
* @Column(type="string", length=7, nullable=true)
*/
protected $posts_published_date;
/**
* @Column(type="integer", length=3, nullable=true)
*/
protected $posts_published_limit;
エンティティで属性を使用する:
public function setPostsPublishedToday($value){
$today = date("now");
if ($today != $this->posts_published_date){
$this->posts_published_today = 1;
debug($this->posts_published_date . " != " . $today, "1");
$this->posts_published_date = $today;
debug($this->posts_published_date . " == " . $today, "2");
} else {
$this->posts_published_today = $value;
}
}
2 つのデバッグは、次の出力で実行されます。
Debug 1: != 220136
Debug 2: 220136 == 220136
posts_published_dateはデータベースに保存されませんが、posts_published_todayは取得され、正常に保存されます。