$hpaystmt = $con->_con->prepare(".....");
object(PDOStatement)#7 (1) { ["queryString"]=> string(1515) " INSERT INTO hpay ( enccode, orno, hpercode, acctno, amt, curcode, paytype, paycode, entryby, payctr, chrgcode, itemcode, chrgtbl) VALUES ( '000060000000000101783710/14/201722:00:00', '00000000033', '000000001017837', '2017-000165903', '1500', 'PESO', 'F', 'C', '', '1', 'DR', 'DR1', 'MISC') "}====object(PDOStatement)#8 (1) { ["queryString"]=> string(1517) " INSERT INTO hpay ( enccode, orno, hpercode, acctno, amt, curcode, paytype, paycode, entryby, payctr, chrgcode, itemcode, chrgtbl) VALUES ( '000060000000000101783710/14/201722:00:00', '00000000033', '000000001017837', '2017-000165903', '100', 'PESO', 'F', 'C', '', '2', 'BIRTC', '085', 'MISC') "}
I get the above code when from
ini_set('display_errors', 1);
var_dump($hpaystmt);
$hpayinsert = $hpaystmt->execute();
echo "==";
echo $hpaystmt->execute() === TRUE ;
echo "==";
My aim is to check if the insert is success or not but echo $hpaystmt->execute() === TRUE ; this line always return blank that is why i alwats get
}==== in echo;
I dont get any error from display error and also I wrap this in try catch and I always go in try part not catch.
How can I check this for success insert?
OTHER INFO:
I want to check if success so that if it fails I want to rollback the database my var $hpayinsert is set to $hpayinsert = true; before the inserting. then after i check for true or false then commit or rollback depending on the value of that var.
UPDATE:
after putting print_r($hpaystmt->errorInfo()); I get:
Array( [0] => 22001 [1] => 8152 [2] => [Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated. (SQLExecute[8152] at ext\pdo_odbc\odbc_stmt.c:254) [3] => 22001)Array( [0] => 22001 [1] => 8152 [2] => [Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated. (SQLExecute[8152] at ext\pdo_odbc\odbc_stmt.c:254) [3] => 22001)
executetwice. You should only do it once. If you need to check the result then store the result or compare it inline. In this case you'd check$hpayinsertinstead of doing a second execute - apokryfos