I'm trying to build a SQL object using ZF2's Db\SQL.
Below is my code.
$sql = new Sql($this->database);
$predicate = new Where();
$query = $sql->select();
$query->from('sessions');
$query->columns(array('sessiondata'));
$query->where($predicate->equalTo('sessionid', $sessionId));
$query->where($predicate->greaterThan('expire', new Expression("NOW()")));
As you can read, I'm doing a session read.
The preparing is failing on the execute because of the [last] where property:
$query->where($predicate->greaterThan('expire', 'NOW()'));
Unfortunately, ZF2 doesn't tell me why it's failed, all I know is that Statement could not be executed
What am I doing wrong in the above?
I think that prepare is interpreting the thing as literally as it can, hence the presence of the mysql function Now()
is causing it to fail. How do I get past this?
EDIT: Actually, it's the execution that's failing.