Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get nextId using insertGetId. #567

Open
forests-k opened this issue Mar 4, 2020 · 1 comment
Open

Get nextId using insertGetId. #567

forests-k opened this issue Mar 4, 2020 · 1 comment
Labels

Comments

@forests-k
Copy link

forests-k commented Mar 4, 2020

Summary of problem or feature request

When using this code:

$nextId = \DB::table('table')->insertGetId([]);

I get the following exception:


[2020-03-04 17:11:26] local.ERROR: Undefined index: object {"exception":"[object] [2020-03-04 17:25:34] local.ERROR: Undefined index: object {"exception":"[object] (ErrorException(code: 0): Undefined index: object at /var/www/html/vendor/yajra/laravel-oci8/src/Oci8/Query/Grammars/OracleGrammar.php:253)
[stacktrace]
#0 /var/www/html/vendor/yajra/laravel-oci8/src/Oci8/Query/Grammars/OracleGrammar.php(253): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined index...', '/var/www/html/v...', 253, Array)
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2155): Yajra\\Oci8\\Query\\Grammars\\OracleGrammar->compileInsertGetId(Object(Yajra\\Oci8\\Query\\OracleBuilder), Array, 'id')

this code given error
$backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4)[2]['object'];

Code snippet of problem

The way that I'm trying to connect looks like this:

config\oracle.php

<?php

return [
    'oracle' => [
        'driver'         => 'oracle',
        'tns'            => env('ORACLE_DB_TNS', ''),
        'host'           => env('ORACLE_DB_HOST'),
        'port'           => env('ORACLE_DB_PORT', '1521'),
        'database'       => env('ORACLE_DB_DATABASE'),
        'username'       => env('ORACLE_DB_USER'),
        'password'       => env('ORACLE_DB_PASSWORD'),
        'charset'        => env('ORACLE_DB_CHARSET', 'JA16SJIS'),
        'prefix'         => env('ORACLE_DB_PREFIX', ''),
        'prefix_schema'  => env('ORACLE_DB_SCHEMA_PREFIX', ''),
    ],
];

System details

  • linux(docker container php:7,2-fpm)
  • PHP 7.2
  • Laravel 5.5.*
  • Laravel-OCI8 5.5.*
@forests-k forests-k changed the title ORacleGrammar.php line253 Undefined index: object {"exception":"[object] (ErrorException(code: 0): Undefined index: object OracleGrammar.php line253 Undefined index: object {"exception":"[object] (ErrorException(code: 0): Undefined index: object Mar 4, 2020
@yajra
Copy link
Owner

yajra commented Dec 6, 2020

Is it the recommended way to get the next id? I think you should be getting it directly from the sequence?

DB::getSequence()->nextValue('USERS_ID_SEQ');

@yajra yajra added the question label Dec 6, 2020
@yajra yajra changed the title OracleGrammar.php line253 Undefined index: object {"exception":"[object] (ErrorException(code: 0): Undefined index: object Get nextId using insertGetId. Dec 6, 2020
@yajra yajra added bug and removed question labels Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants