[Koha-bugs] [Bug 20591] New: DBI->last_insert_id does not work as expected

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Apr 16 18:41:34 CEST 2018


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20591

            Bug ID: 20591
           Summary: DBI->last_insert_id does not work as expected
 Change sponsored?: ---
           Product: Koha
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: jonathan.druart at bugs.koha-community.org
        QA Contact: testopia at bugs.koha-community.org

Try the following code:

use Koha::Database;
use Koha::Cities;
use Koha::AuthorisedValues;
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;

my $city = Koha::City->new({ city_name => 'name' })->store;
say $city->cityid;
say $dbh->last_insert_id( undef, undef, 'cities', undef );
say $dbh->last_insert_id( undef, undef, 'not_exist', undef );

say "===";
my $av = Koha::AuthorisedValue->new({category => 'LOC', authorised_value =>
'just_a_test'})->store;
say $av->id;
say $dbh->last_insert_id( undef, undef, 'authorised_values', undef );
say $dbh->last_insert_id( undef, undef, 'cities', undef );
say $dbh->last_insert_id( undef, undef, 'not_exist', undef );

It will display:
12
12
12
===
401
401
401
401

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list