The following will echo $response
of 1 if there is no error regardless whether a record was inserted.
I read PDO mysql: How to know if insert was successful, however, it just describes if the query was unsuccessful presumably doe to an error.
How can I confirm whether a record was inserted or not?
<?php
$sql='INSERT INTO t3(id,data) SELECT id,data FROM t2 WHERE id=?';
$stmt=db::db()->prepare($sql);
$response=$stmt->execute(array(123));
echo($response);
?>
PDO::rowCount
will return the number of affected rows.
So you could: echo $stmt->rowCount();
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments