Hi,
I have codes like below
$statement = $this->adapter->createStatement("SELECT UUID() as user_id");
$result = $statement->execute();
$row = $result->current();
$user_id = $row['user_id'];
$this->conn = $this->adapter->getDriver()->getConnection();
try {
$this->conn->beginTransaction();
$data = [
'user_id' => $user_id,
'email' => $user->email,
'password' => password_hash($user->password, PASSWORD_DEFAULT, ['cost' => 10]),
'created_at' => $user->created_at,
];
$this->tableGateway->insert($data);
$this->conn->commit();
} catch (Exception $e) {
$this->conn->rollback();
throw $e;
}
When i execute it i get an error:
Laminas\Db\Adapter\Exception\InvalidQueryException:
Statement couldn’t be produced with sql: INSERT INTO users
(user_id
, email
, password
, created_at
) VALUES (?, ?, ?, ?)
When i remove the first lines it works well.
$statement = $this->adapter->createStatement("SELECT UUID() as user_id");
$result = $statement->execute();
$row = $result->current();
$user_id = $row['user_id'];
Where am I doing wrong ?
Thanks.