看下列程式範例就知道了:
$query = "update `payment` set `status` = '2', `tx_id` = ?, `tx_method` = ?
where `payment_id` = ? and `status` = '1'";
$stmt = $this->pdo->prepare ( $query );
$stmt->bindParam ( 1, $tx_id );
$stmt->bindParam ( 2, $tx_type );
$stmt->bindParam ( 3, $payment_id );
$result = $stmt->execute ();
if($result === true) {
if($stmt->rowCount() == 1) {
$this->log_info ( " updated successful." );
} else {
$this->log_info ( " payment updated failed." );
$this->pdo->rollBack ();
return false;
}
} else {
$this->pdo->rollBack ();
$this->log_info ( " updated failed. Query Execution Failed." );
return false;
}
沒有留言:
張貼留言