laravel-oci8 icon indicating copy to clipboard operation
laravel-oci8 copied to clipboard

Cannot delete and update

Open mhdyuzi opened this issue 5 years ago • 3 comments

Summary of problem or feature request

Hi, i am using yajra laravel-oci8 package with Laravel 6.2. I am having problem with crud operation for update and delete function (i am using resource controller).

store function run successfully as usual. the data is inserted into the database. However, the update and delete didn't work as expected. save() command in update function return true, but the changes is not written to the database. i had check both $request and $work object with dd and both objects exist with right data.

I am suspecting it has something to do with oracle default autocommit off. I tried the same code with MySQL table and it works. How do i enable oracle autocommit using this laravel-oci8 or how do i call commit using Eloquent? I also had try to put the save() command in DB transaction but still no luck. Please help.

Code snippet of problem

    public function store(Request $request)
    {
        $work = new Work();
        $work->id = $request->workid;
        $work->name = $request->workname;
        $work->save();

        return redirect('work');
    }

    public function update(Request $request, Work $work)
    {
        $work->name = $request->workname;
        $work->save();
        
        return redirect('work');
    }

    public function destroy(Work $work)
    {
        $work->delete();
        return redirect('work');
    }

<div class="card-body">
                    <form action="{{ route('work.update',$work->id) }}" method="POST">
                        @method('PUT')
                        @csrf
                        <div class="form-group row">
                            <label for="workid" class="col-md-2 col-form-label text-md-right">ID</label>

                            <div class="col-md-10">
                                <input id="workid" type="text" class="form-control @error('workid') is-invalid @enderror" name="workid" value="{{ $work->id }}" required autocomplete="workid" autofocus>

                                @error('workid')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="workname" class="col-md-2 col-form-label text-md-right">Name</label>

                            <div class="col-md-10">
                                <input id="workname" type="text" class="form-control @error('workname') is-invalid @enderror" name="workname" value="{{$work->name}}" required autocomplete="workname">

                                @error('workname')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row mb-0">
                            <div class="col-md-6 offset-md-2">
                                <button type="submit" class="btn btn-primary">
                                    Update
                                </button>
                            </div>
                        </div>
                    </form>

System details

  • php artisan serve on Windows 10
  • PHP Version 7.2
  • Laravel Version 6.2
  • Laravel-OCI8 Version 6.1

mhdyuzi avatar Apr 23 '20 08:04 mhdyuzi

Can you write a route ?

sciracioglu avatar Jun 24 '20 10:06 sciracioglu

I am suspecting it has something to do with oracle default autocommit off

Auto-commit is on by default when using the package unless you have some codes that opens a transaction.

yajra avatar Dec 06 '20 12:12 yajra

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 18 '22 04:10 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Oct 25 '22 04:10 github-actions[bot]