最合适的回答,由SO网友:Paul G. 整理而成
在尝试写入数据库之前,always 验证您输入的值:
$fValid = true;
if ( !isset( $payment->status ) ) {
echo \'Error: Payment status is not set\';
$fValid = false;
}
if ( !isset( $order_id ) ) {
echo \'Error: Order ID is not set\';
$fValid = false;
}
if ( $fValid ) {
// Update database
$fSuccess = $wpdb->update( $wpdb->prefix . \'mollie_transactions\',
array(
\'status\' => $payment->status
),
array(
\'transaction_id\' => $order_id
)
);
echo sprintf( \'Update %s where Payment Status was %s and Transaction ID was %s\', $fSuccess? \'Succeeded\':\'Failed\', $payment->status, $order_id );
}
干杯。