Reputation: 2777
I am trying to do a query onto my database with the following code.
public function getFreeFields($date){
print_r($date);
$db = Zend_Registry::get('db');
$select = $db->select()
->from(array('f' => $this->_tablename()), array('f.fie_id','f.fie_name'))
->join('reservation','reservation.res_field = f.fie_id')
->where('reservation.res_date_from > ?'. $date)
->where('reservation.res_date_till < ?'. $date);
$result = $db->fetchRow($select);
$data = $this->_mapper->toObject( is_array($result) ? $result : array() );
return $data;
}
But it crashes with the following error.
Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound'
When I die after the print_r, I got the correct date that I give to the request.
Any help?
Upvotes: 0
Views: 62
Reputation: 30488
change this
->where('r.res_date_from > ?'. $date)
->where('r.res_date_till < ?'. $date);
to
->where('r.res_date_from > ?', $date)
->where('r.res_date_till < ?', $date);
Upvotes: 2