From 8bb9cf18f9bc7855c78a5854b85b7a65d6308ead Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 30 Apr 2025 13:31:59 +0300 Subject: [PATCH] Rename `getLastInsertID()` method in `ConnectionInterface` to `getLastInsertId()` --- src/Connection.php | 2 +- tests/CommandTest.php | 4 ++-- tests/PdoConnectionTest.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 91c23451..db21a52a 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -62,7 +62,7 @@ public function getColumnFactory(): ColumnFactoryInterface * @throws InvalidCallException * @throws Throwable */ - public function getLastInsertID(?string $sequenceName = null): string + public function getLastInsertId(?string $sequenceName = null): string { if ($sequenceName === null) { throw new InvalidArgumentException('Oracle not support lastInsertId without sequence name.'); diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 1c0bfba1..dfcad456 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -373,7 +373,7 @@ public function testsInsertQueryAsColumnValue(): void $command->delete('{{order_with_null_fk}}')->execute(); $command->insert('{{order}}', ['customer_id' => 1, 'created_at' => $time, 'total' => 42])->execute(); $columnValueQuery = new Query($db); - $orderId = $db->getLastInsertID('order_SEQ'); + $orderId = $db->getLastInsertId('order_SEQ'); $columnValueQuery->select('created_at')->from('{{order}}')->where(['id' => $orderId]); $command->insert( '{{order_with_null_fk}}', @@ -558,7 +558,7 @@ public function testNoTablenameReplacement(): void ], )->execute(); - $customerId = $db->getLastInsertID('customer_SEQ'); + $customerId = $db->getLastInsertId('customer_SEQ'); $customer = $command->setSql( <<insert('item', ['name' => 'Yii2 starter', 'category_id' => 1])->execute(); $command->insert('item', ['name' => 'Yii3 starter', 'category_id' => 1])->execute(); - $this->assertSame('7', $db->getLastInsertID('item_SEQ')); + $this->assertSame('7', $db->getLastInsertId('item_SEQ')); $db->close(); } @@ -57,7 +57,7 @@ public function testGetLastInsertIDWithException(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Oracle not support lastInsertId without sequence name.'); - $db->getLastInsertID(); + $db->getLastInsertId(); } /** @@ -77,8 +77,8 @@ public function testGetLastInsertIdWithTwoConnection() $sql = 'INSERT INTO {{profile}}([[description]]) VALUES (\'non duplicate2\')'; $db2->createCommand($sql)->execute(); - $this->assertNotEquals($db1->getLastInsertID('profile_SEQ'), $db2->getLastInsertID('profile_SEQ')); - $this->assertNotEquals($db2->getLastInsertID('profile_SEQ'), $db1->getLastInsertID('profile_SEQ')); + $this->assertNotEquals($db1->getLastInsertId('profile_SEQ'), $db2->getLastInsertId('profile_SEQ')); + $this->assertNotEquals($db2->getLastInsertId('profile_SEQ'), $db1->getLastInsertId('profile_SEQ')); $db1->close(); $db2->close();