I am trying to update a record with the DBAL Query builder and it does not seem to be working. The data
column that I am trying to set will only work if I replace the test
example value I have here with a number.
In that case it will update my record perfectly fine.
Even if I use setParameter
for it as well it will silently fail.
$queryBuilder = $this->connection
->update($this->table)
->where('id = ?')
->set('data', 'test')
->setParameter(0, $sessionId);
Am I mis-using this or is something else going on?
Edit:
The insert statement works perfectly fine:
$queryBuilder = $this->connection
->insert($this->table)
->values([
'id' => '?',
'secure' => '?',
'modified' => '?',
'lifetime' => '?',
'user_hash' => '?',
'data' => '?',
])
->setParameter(0, $sessionId)
->setParameter(1, 'y')
->setParameter(2, time())
->setParameter(3, $this->minutes)
->setParameter(4, 'test')
->setParameter(5, $data);
}
You can use parameters in update
the same way you use it in insert
:
$queryBuilder = $this->connection
->update($this->table)
->set('data', '?')
->where('id = ?')
->setParameter(0, 'test')
->setParameter(1, $sessionId);