Skip to content

Commit faea3d9

Browse files
authored
Rename getLastInsertID() method in ConnectionInterface to getLastInsertId() (#322)
1 parent efa778f commit faea3d9

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Connection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function getColumnFactory(): ColumnFactoryInterface
6262
* @throws InvalidCallException
6363
* @throws Throwable
6464
*/
65-
public function getLastInsertID(?string $sequenceName = null): string
65+
public function getLastInsertId(?string $sequenceName = null): string
6666
{
6767
if ($sequenceName === null) {
6868
throw new InvalidArgumentException('Oracle not support lastInsertId without sequence name.');

tests/CommandTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public function testsInsertQueryAsColumnValue(): void
373373
$command->delete('{{order_with_null_fk}}')->execute();
374374
$command->insert('{{order}}', ['customer_id' => 1, 'created_at' => $time, 'total' => 42])->execute();
375375
$columnValueQuery = new Query($db);
376-
$orderId = $db->getLastInsertID('order_SEQ');
376+
$orderId = $db->getLastInsertId('order_SEQ');
377377
$columnValueQuery->select('created_at')->from('{{order}}')->where(['id' => $orderId]);
378378
$command->insert(
379379
'{{order_with_null_fk}}',
@@ -558,7 +558,7 @@ public function testNoTablenameReplacement(): void
558558
],
559559
)->execute();
560560

561-
$customerId = $db->getLastInsertID('customer_SEQ');
561+
$customerId = $db->getLastInsertId('customer_SEQ');
562562

563563
$customer = $command->setSql(
564564
<<<SQL

tests/PdoConnectionTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testGetLastInsertID(): void
3535
$command->insert('item', ['name' => 'Yii2 starter', 'category_id' => 1])->execute();
3636
$command->insert('item', ['name' => 'Yii3 starter', 'category_id' => 1])->execute();
3737

38-
$this->assertSame('7', $db->getLastInsertID('item_SEQ'));
38+
$this->assertSame('7', $db->getLastInsertId('item_SEQ'));
3939

4040
$db->close();
4141
}
@@ -57,7 +57,7 @@ public function testGetLastInsertIDWithException(): void
5757
$this->expectException(InvalidArgumentException::class);
5858
$this->expectExceptionMessage('Oracle not support lastInsertId without sequence name.');
5959

60-
$db->getLastInsertID();
60+
$db->getLastInsertId();
6161
}
6262

6363
/**
@@ -77,8 +77,8 @@ public function testGetLastInsertIdWithTwoConnection()
7777
$sql = 'INSERT INTO {{profile}}([[description]]) VALUES (\'non duplicate2\')';
7878
$db2->createCommand($sql)->execute();
7979

80-
$this->assertNotEquals($db1->getLastInsertID('profile_SEQ'), $db2->getLastInsertID('profile_SEQ'));
81-
$this->assertNotEquals($db2->getLastInsertID('profile_SEQ'), $db1->getLastInsertID('profile_SEQ'));
80+
$this->assertNotEquals($db1->getLastInsertId('profile_SEQ'), $db2->getLastInsertId('profile_SEQ'));
81+
$this->assertNotEquals($db2->getLastInsertId('profile_SEQ'), $db1->getLastInsertId('profile_SEQ'));
8282

8383
$db1->close();
8484
$db2->close();

0 commit comments

Comments
 (0)