1
未満/以上のSQLクエリZF2グレータークエリ
Select * FROM table_name
WHERE category = 'category_name'
AND created < 'todays_date'
AND created > 'yesterdays_date'
もORDERとLIMIT条件を追加する必要があります。 ZF2でこれをどのように達成できますか?この場合、<=
と>=
:
$rowset = $this->tableGateway->select(function ($select) {
$select->where(['category' => $this->category]);
$select->order('id Desc');
$select->limit($this->limit);
$DBtimeNow = new \DateTime();
$select->lessThanOrEqualTo("created", $DBtimeNow->format('Y-m-d H:i:s'));
$DBtimeNow->sub(new DateInterval('P1D'));
$select->greaterThanOrEqualTo("created", $DBtimeNow->format('Y-m-d H:i:s'));
});