My problem is that with a specific table in my database even if I use a simple INSERT INTO
query the data gets updated instead of giving me a "Duplicate" error if the primary key already exists.
Structure of the table:
user_id (PRIMARY_KEY) | email (VARCHAR) | token (VARCHAR) | created (DATETIME)
If I excecute this:
$sql = "INSERT INTO
email_confirmation (
user_id,
email,
token,
created
) VALUES (
:user_id,
:email,
:token,
NOW()
)";
$query = $this->connection->prepare($sql);
$values = [
':user_id' => $customer['id'],
':email' => $customer['email'],
':token' => $token
];
$query->execute($values);
It will update my row instead of giving me an error if primary key already exists. Can anyone explain me why is this happening?