Skip to content

Commit 847e72d

Browse files
committed
refactor: remove deprecations in Database
1 parent f733c6e commit 847e72d

File tree

18 files changed

+105
-319
lines changed

18 files changed

+105
-319
lines changed

system/Database/BaseBuilder.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,24 +2260,6 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
22602260
return str_replace('{:_table_:}', $data, $sql);
22612261
}
22622262

2263-
/**
2264-
* Allows key/value pairs to be set for batch inserts
2265-
*
2266-
* @param mixed $key
2267-
*
2268-
* @return $this|null
2269-
*
2270-
* @deprecated
2271-
*/
2272-
public function setInsertBatch($key, string $value = '', ?bool $escape = null)
2273-
{
2274-
if (! is_array($key)) {
2275-
$key = [[$key => $value]];
2276-
}
2277-
2278-
return $this->setData($key, $escape);
2279-
}
2280-
22812263
/**
22822264
* Compiles an insert query and returns the sql
22832265
*
@@ -2709,28 +2691,6 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
27092691
return str_replace('{:_table_:}', $data, $sql);
27102692
}
27112693

2712-
/**
2713-
* Allows key/value pairs to be set for batch updating
2714-
*
2715-
* @param array|object $key
2716-
*
2717-
* @return $this
2718-
*
2719-
* @throws DatabaseException
2720-
*
2721-
* @deprecated
2722-
*/
2723-
public function setUpdateBatch($key, string $index = '', ?bool $escape = null)
2724-
{
2725-
if ($index !== '') {
2726-
$this->onConstraint($index);
2727-
}
2728-
2729-
$this->setData($key, $escape);
2730-
2731-
return $this;
2732-
}
2733-
27342694
/**
27352695
* Compiles a delete string and runs "DELETE FROM table"
27362696
*
@@ -3550,18 +3510,6 @@ protected function setBind(string $key, $value = null, bool $escape = true): str
35503510
return $key . '.' . $count;
35513511
}
35523512

3553-
/**
3554-
* Returns a clone of a Base Builder with reset query builder values.
3555-
*
3556-
* @return $this
3557-
*
3558-
* @deprecated
3559-
*/
3560-
protected function cleanClone()
3561-
{
3562-
return (clone $this)->from([], true)->resetQuery();
3563-
}
3564-
35653513
/**
35663514
* @param mixed $value
35673515
*/

system/Database/BaseConnection.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,6 @@ abstract class BaseConnection implements ConnectionInterface
193193
*/
194194
protected $compress = false;
195195

196-
/**
197-
* Strict ON flag
198-
*
199-
* Whether we're running in strict SQL mode.
200-
*
201-
* @var bool|null
202-
*
203-
* @deprecated 4.5.0 Will move to MySQLi\Connection.
204-
*/
205-
protected $strictOn;
206-
207196
/**
208197
* Settings for a failover connection.
209198
*

system/Database/Forge.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ class Forge
108108
*/
109109
protected $createTableStr = "%s %s (%s\n)";
110110

111-
/**
112-
* CREATE TABLE IF statement
113-
*
114-
* @var bool|string
115-
*
116-
* @deprecated This is no longer used.
117-
*/
118-
protected $createTableIfStr = 'CREATE TABLE IF NOT EXISTS';
119-
120111
/**
121112
* CREATE TABLE keys flag
122113
*
@@ -565,7 +556,7 @@ public function createTable(string $table, bool $ifNotExists = false, array $att
565556
return true;
566557
}
567558

568-
$sql = $this->_createTable($table, false, $attributes);
559+
$sql = $this->_createTable($table, $attributes);
569560

570561
if (($result = $this->db->query($sql)) !== false) {
571562
if (isset($this->db->dataCache['table_names']) && ! in_array($table, $this->db->dataCache['table_names'], true)) {
@@ -586,13 +577,11 @@ public function createTable(string $table, bool $ifNotExists = false, array $att
586577
}
587578

588579
/**
589-
* @param array $attributes Table attributes
580+
* @param array<string, mixed> $attributes Table attributes
590581
*
591582
* @return string SQL string
592-
*
593-
* @deprecated $ifNotExists is no longer used, and will be removed.
594583
*/
595-
protected function _createTable(string $table, bool $ifNotExists, array $attributes)
584+
protected function _createTable(string $table, array $attributes)
596585
{
597586
$processedFields = $this->_processFields(true);
598587

system/Database/OCI8/Forge.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ class Forge extends BaseForge
3434
*/
3535
protected $createDatabaseStr = false;
3636

37-
/**
38-
* CREATE TABLE IF statement
39-
*
40-
* @var false
41-
*
42-
* @deprecated This is no longer used.
43-
*/
44-
protected $createTableIfStr = false;
45-
4637
/**
4738
* DROP TABLE IF EXISTS statement
4839
*

system/Database/SQLSRV/Connection.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -537,40 +537,6 @@ protected function execute(string $sql)
537537
return $stmt;
538538
}
539539

540-
/**
541-
* Returns the last error encountered by this connection.
542-
*
543-
* @return array<string, int|string>
544-
*
545-
* @deprecated Use `error()` instead.
546-
*/
547-
public function getError()
548-
{
549-
$error = [
550-
'code' => '00000',
551-
'message' => '',
552-
];
553-
554-
$sqlsrvErrors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
555-
556-
if (! is_array($sqlsrvErrors)) {
557-
return $error;
558-
}
559-
560-
$sqlsrvError = array_shift($sqlsrvErrors);
561-
if (isset($sqlsrvError['SQLSTATE'])) {
562-
$error['code'] = isset($sqlsrvError['code']) ? $sqlsrvError['SQLSTATE'] . '/' . $sqlsrvError['code'] : $sqlsrvError['SQLSTATE'];
563-
} elseif (isset($sqlsrvError['code'])) {
564-
$error['code'] = $sqlsrvError['code'];
565-
}
566-
567-
if (isset($sqlsrvError['message'])) {
568-
$error['message'] = $sqlsrvError['message'];
569-
}
570-
571-
return $error;
572-
}
573-
574540
/**
575541
* The name of the platform in use (MySQLi, mssql, etc)
576542
*/

system/Database/SQLSRV/Forge.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ class Forge extends BaseForge
9494
*/
9595
protected $fkAllowActions = ['CASCADE', 'SET NULL', 'NO ACTION', 'RESTRICT', 'SET DEFAULT'];
9696

97-
/**
98-
* CREATE TABLE IF statement
99-
*
100-
* @var string
101-
*
102-
* @deprecated This is no longer used.
103-
*/
104-
protected $createTableIfStr;
105-
10697
/**
10798
* CREATE TABLE statement
10899
*

system/Database/Seeder.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use CodeIgniter\CLI\CLI;
1717
use CodeIgniter\Exceptions\InvalidArgumentException;
1818
use Config\Database;
19-
use Faker\Factory;
20-
use Faker\Generator;
2119

2220
/**
2321
* Class Seeder
@@ -66,13 +64,6 @@ class Seeder
6664
*/
6765
protected $silent = false;
6866

69-
/**
70-
* Faker Generator instance.
71-
*
72-
* @deprecated
73-
*/
74-
private static ?Generator $faker = null;
75-
7667
/**
7768
* Seeder constructor.
7869
*/
@@ -104,20 +95,6 @@ public function __construct(Database $config, ?BaseConnection $db = null)
10495
}
10596
}
10697

107-
/**
108-
* Gets the Faker Generator instance.
109-
*
110-
* @deprecated
111-
*/
112-
public static function faker(): ?Generator
113-
{
114-
if (! self::$faker instanceof Generator && class_exists(Factory::class)) {
115-
self::$faker = Factory::create();
116-
}
117-
118-
return self::$faker;
119-
}
120-
12198
/**
12299
* Loads the specified seeder and runs it.
123100
*

tests/_support/Database/Seeds/CITestSeeder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ public function run(): void
185185
}
186186

187187
if ($this->db->DBDriver === 'MySQLi') {
188+
$data['type_test'][0]['type_time'] = '15:22:00';
189+
188190
$data['ci_sessions'][] = [
189191
'id' => 'ci_session:1f5o06b43phsnnf8if6bo33b635e4p2o',
190192
'ip_address' => '127.0.0.1',

tests/system/Database/BaseConnectionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public function testSavesConfigOptions(): void
8484
$this->assertSame('', $db->swapPre);
8585
$this->assertFalse($db->encrypt);
8686
$this->assertFalse($db->compress);
87-
$this->assertTrue($db->strictOn);
8887
$this->assertSame([], $db->failover);
8988
$this->assertSame([
9089
'date' => 'Y-m-d',

tests/system/Database/Builder/UpdateTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ public function testUpdateBatch(): void
253253
public function testSetUpdateBatchWithoutEscape(): void
254254
{
255255
$builder = new BaseBuilder('jobs', $this->db);
256-
$escape = false;
257-
258-
$builder->setUpdateBatch([
256+
$builder->setData([
259257
[
260258
'id' => 2,
261259
'name' => 'SUBSTRING(name, 1)',
@@ -266,7 +264,7 @@ public function testSetUpdateBatchWithoutEscape(): void
266264
'name' => 'SUBSTRING(name, 2)',
267265
'description' => 'SUBSTRING(description, 4)',
268266
],
269-
], 'id', $escape);
267+
], false);
270268

271269
$this->db->shouldReturn('execute', new class () {});
272270
$builder->updateBatch(null, 'id');

0 commit comments

Comments
 (0)