laravel-oci8
laravel-oci8 copied to clipboard
DB rollBack not working properly
Summary of problem or feature request
Even using rollback the data is updated in the database
Code snippet of problem
\DB::beginTransaction();
AclUsers::where('id', 1538)->update(['name' => 'EDSON ALVES DE OLIVEIRA J']);
\DB::rollBack();

System details
- Operating System PRETTY_NAME="Debian GNU/Linux 9 (stretch)" NAME="Debian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)" ID=debian
- PHP Version PHP 7.2.16
- Laravel Version 5.8
- Laravel-OCI8 Version 5.8
I noticed that using DB :: statement works:
\DB::transaction(function($conn){
\DB::statement("update acl_users set name = 'pirilampo' where id = 1538");
\DB::rollBack();
Maybe this help you understand what is going on.
My model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class AclUsers extends Model{
protected $connection = 'web';
protected $table = 'acl_users';
public $timestamps = false;
protected $hidden = ['password', 'hash_temp'];
}
help my please. the rollback with the next option not working
function myFunction($p) {
return DB::transaction(function($conn) use ($p) {
try {
$pdo = $conn->getPdo();
$sql = "BEGIN VLS_PK.INSERT_VLC_SP(:P_ID,:P_SMS); END;";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':P_ID', $p->id, PDO::PARAM_INT);
$stmt->bindParam(':P_SMS', $p->sms, PDO::PARAM_STR);
$stmt->execute();
$sql2 = "BEGIN VLS_PK.INSERT_VLB_SP(:P_ID,:P_SMS); END;";
$stmt2 = $pdo->prepare($sql2);
$stmt2->bindParam(':P_ID', $p->id, PDO::PARAM_INT);
$stmt2->bindParam(':P_SMS', $p->sms, PDO::PARAM_STR);
$stmt2->execute();
return true;
} catch (\Throwable $e) {
Log::error('myClass.myFunction' . PHP_EOL . $e->getMessage());
return false;
}
});
}
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.