php - How to bind datetime field between two string value -


i have method :

public function getcustomdateorders(string $startday,string $endday,string $food) :array {     $result = $this->_em->createquerybuilder()         ->select         (             'orderentity.name'             'orderentity.created'         )         ->from($this->entityclass , 'orderentity')         ->leftjoin(             'directory\food',             'food',             'with',             'food.id = orderentity.foodid '         )         ->where("food.id =:food")         ->andwhere("orderentity.status =:active")         ->andwhere("startdate<:orderentity.ordercreated >:endday")         ->getquery()         ->setparameters([             "food"    =>       $food,             "active"        =>  1,             "startdate"     =>  $startday,             "endday"        =>  $endday         ])         ->getscalerresult();          ->getscalarresult();  } 

i have couple of values :

$startday equal "2016-010-17 00:00:00" (string)

$endday equal "2016-10-03 00:00:00" (string)

and order.created (one of order's fields) datetime.

i want fetch order order entity has created field between $startday , $endday. how solve it?

use between:

public function getcustomdateorders(string $startday,string $endday,string $food) :array {     $result = $this->_em->createquerybuilder()         ->select         (             'orderentity.name'             'orderentity.created'         )         ->from($this->entityclass , 'orderentity')         ->leftjoin(             'directory\food',             'food',             'with',             'food.id = orderentity.foodid '         )         ->where("food.id =:food")         ->andwhere("orderentity.status =:active")         ->andwhere("orderentity.ordercreated between :startday , :endday")         ->setparameters([             "food"    =>       $food,             "active"        =>  1,             "startday"     =>  $startday,             "endday"        =>  $endday         ])        ->getquery()        ->getscalerresult(); } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -