I am newer to zend Framework and i facing one issue in query, Please help me.
$rowset = $this->tableGateway->select(function (Select $select) {
$syear = date('Y');
$select->where(array(
'YEAR(date) = ?' => $syear,
'user_id = ?' =>$myid,
));
$select->order('id DESC');
});
$counter3= count($rowset);
Here, i want count of current year record and userid is fixed like 50 then output is all data with 50 userid and current year
here my year condition in WHERE succesufully work but 'user_id = ?' =>$myid
'user_id = ?' =>$myid
it's not working, suppose $myid value is 50 ,
but if i pass 50 value directly like 'user_id = ?' =>50
'user_id = ?' =>50
then its working
What is the problem here,
Thanks in advance.
i am guesting $myid
is defined before the select function is called. in this case u need to tell your select function to use this variable.
$rowset = $this->tableGateway->select(function (Select $select) use($myid) {});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.