cakephp - date beetween and query giving error -
$attdata= $attendeestable->find()->where( [ 'meeting_id =' => $meeting_id, 'email =' => $data['email'], 'created_at between ? , ?'=> array( $finaldate, $enddate ) ]) ->count();
error: call member function format() on non-object file /var/www/webinar.mj/vendor/cakephp/cakephp/src/database/type/datetimetype.php
line: 104
the right way is
$attdata= $attendeestable->find() ->where([ 'meeting_id =' => $meeting_id, 'email =' => $data['email'] ]) ->where(function ($exp, $q) use($finaldate, $enddate) { $exp->between('created_at ', $finaldate, $enddate); return $exp; }) ->count();
you can do
$attdata= $attendeestable->find()->where( [ 'meeting_id =' => $meeting_id, 'email =' => $data['email'], 'created_at between :foo , :bar' ]) ->bind(':foo', $finaldate, 'date') ->bind(':bar', $enddate, 'date') ; ->count();
Comments
Post a Comment