Im currently running Laravel 5.8. I've configured a few Oracle databases in my project whereby we're required to sometimes run some SQL update/insert statements against oracle databases. These are input via a GUI and submitted into the backend which is validated and then run. I'm using yajra/oci8 package to plugin to these databases and using raw SQL queries for the update/insert statements. To execute the SQL, i use this:
$rowsUpdated = DB::connection($database)->$sqlType($sql);```
$database = the database connection to run the SQL against
$sqlType = this is insert/update depending on the input
$sql = this is the raw SQL update/insert statement to run
When i run the update statements, $rowsUpdated
correctly shows the number of rows that were affected. However when i run the following insert statement, it only returns a value of 1 every time. For example, the insert statement below inserts 2 rows, but the return value is only 1:
INSERT ALL
into schema.table (ORDER_ID, PRODUCT_TYPE, created_dtm, ORDER_TYPE, ORDER_STATUS, CANCELLING_STATE, last_modified_dtm, OPERATOR_CODE)
values (10000006, 'FTTC', sysdate - 1024, 'Provide', 'Completed', null, sysdate - 1020, 'test')
into schema.table (ORDER_ID, PRODUCT_TYPE, created_dtm, ORDER_TYPE, ORDER_STATUS, CANCELLING_STATE, last_modified_dtm, OPERATOR_CODE)
values (10000007, 'FTTC', sysdate - 1024, 'Provide', 'Completed', null, sysdate - 1020, 'test')
SELECT * FROM DUAL;
How can I get a count of the number of rows inserted?
Edit: Thanks for providing the answer. Laravel Raw DB Insert Affected Rows