Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2260,24 +2260,6 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
return str_replace('{:_table_:}', $data, $sql);
}

/**
* Allows key/value pairs to be set for batch inserts
*
* @param mixed $key
*
* @return $this|null
*
* @deprecated
*/
public function setInsertBatch($key, string $value = '', ?bool $escape = null)
{
if (! is_array($key)) {
$key = [[$key => $value]];
}

return $this->setData($key, $escape);
}

/**
* Compiles an insert query and returns the sql
*
Expand Down Expand Up @@ -2709,28 +2691,6 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
return str_replace('{:_table_:}', $data, $sql);
}

/**
* Allows key/value pairs to be set for batch updating
*
* @param array|object $key
*
* @return $this
*
* @throws DatabaseException
*
* @deprecated
*/
public function setUpdateBatch($key, string $index = '', ?bool $escape = null)
{
if ($index !== '') {
$this->onConstraint($index);
}

$this->setData($key, $escape);

return $this;
}

/**
* Compiles a delete string and runs "DELETE FROM table"
*
Expand Down Expand Up @@ -3550,18 +3510,6 @@ protected function setBind(string $key, $value = null, bool $escape = true): str
return $key . '.' . $count;
}

/**
* Returns a clone of a Base Builder with reset query builder values.
*
* @return $this
*
* @deprecated
*/
protected function cleanClone()
{
return (clone $this)->from([], true)->resetQuery();
}

/**
* @param mixed $value
*/
Expand Down
11 changes: 0 additions & 11 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,6 @@ abstract class BaseConnection implements ConnectionInterface
*/
protected $compress = false;

/**
* Strict ON flag
*
* Whether we're running in strict SQL mode.
*
* @var bool|null
*
* @deprecated 4.5.0 Will move to MySQLi\Connection.
*/
protected $strictOn;

/**
* Settings for a failover connection.
*
Expand Down
17 changes: 3 additions & 14 deletions system/Database/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ class Forge
*/
protected $createTableStr = "%s %s (%s\n)";

/**
* CREATE TABLE IF statement
*
* @var bool|string
*
* @deprecated This is no longer used.
*/
protected $createTableIfStr = 'CREATE TABLE IF NOT EXISTS';

/**
* CREATE TABLE keys flag
*
Expand Down Expand Up @@ -565,7 +556,7 @@ public function createTable(string $table, bool $ifNotExists = false, array $att
return true;
}

$sql = $this->_createTable($table, false, $attributes);
$sql = $this->_createTable($table, $attributes);

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

/**
* @param array $attributes Table attributes
* @param array<string, mixed> $attributes Table attributes
*
* @return string SQL string
*
* @deprecated $ifNotExists is no longer used, and will be removed.
*/
protected function _createTable(string $table, bool $ifNotExists, array $attributes)
protected function _createTable(string $table, array $attributes)
{
$processedFields = $this->_processFields(true);

Expand Down
9 changes: 0 additions & 9 deletions system/Database/OCI8/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ class Forge extends BaseForge
*/
protected $createDatabaseStr = false;

/**
* CREATE TABLE IF statement
*
* @var false
*
* @deprecated This is no longer used.
*/
protected $createTableIfStr = false;

/**
* DROP TABLE IF EXISTS statement
*
Expand Down
34 changes: 0 additions & 34 deletions system/Database/SQLSRV/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,40 +537,6 @@ protected function execute(string $sql)
return $stmt;
}

/**
* Returns the last error encountered by this connection.
*
* @return array<string, int|string>
*
* @deprecated Use `error()` instead.
*/
public function getError()
{
$error = [
'code' => '00000',
'message' => '',
];

$sqlsrvErrors = sqlsrv_errors(SQLSRV_ERR_ERRORS);

if (! is_array($sqlsrvErrors)) {
return $error;
}

$sqlsrvError = array_shift($sqlsrvErrors);
if (isset($sqlsrvError['SQLSTATE'])) {
$error['code'] = isset($sqlsrvError['code']) ? $sqlsrvError['SQLSTATE'] . '/' . $sqlsrvError['code'] : $sqlsrvError['SQLSTATE'];
} elseif (isset($sqlsrvError['code'])) {
$error['code'] = $sqlsrvError['code'];
}

if (isset($sqlsrvError['message'])) {
$error['message'] = $sqlsrvError['message'];
}

return $error;
}

/**
* The name of the platform in use (MySQLi, mssql, etc)
*/
Expand Down
9 changes: 0 additions & 9 deletions system/Database/SQLSRV/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,6 @@ class Forge extends BaseForge
*/
protected $fkAllowActions = ['CASCADE', 'SET NULL', 'NO ACTION', 'RESTRICT', 'SET DEFAULT'];

/**
* CREATE TABLE IF statement
*
* @var string
*
* @deprecated This is no longer used.
*/
protected $createTableIfStr;

/**
* CREATE TABLE statement
*
Expand Down
23 changes: 0 additions & 23 deletions system/Database/Seeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use CodeIgniter\CLI\CLI;
use CodeIgniter\Exceptions\InvalidArgumentException;
use Config\Database;
use Faker\Factory;
use Faker\Generator;

/**
* Class Seeder
Expand Down Expand Up @@ -66,13 +64,6 @@ class Seeder
*/
protected $silent = false;

/**
* Faker Generator instance.
*
* @deprecated
*/
private static ?Generator $faker = null;

/**
* Seeder constructor.
*/
Expand Down Expand Up @@ -104,20 +95,6 @@ public function __construct(Database $config, ?BaseConnection $db = null)
}
}

/**
* Gets the Faker Generator instance.
*
* @deprecated
*/
public static function faker(): ?Generator
{
if (! self::$faker instanceof Generator && class_exists(Factory::class)) {
self::$faker = Factory::create();
}

return self::$faker;
}

/**
* Loads the specified seeder and runs it.
*
Expand Down
1 change: 0 additions & 1 deletion tests/system/Database/BaseConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function testSavesConfigOptions(): void
$this->assertSame('', $db->swapPre);
$this->assertFalse($db->encrypt);
$this->assertFalse($db->compress);
$this->assertTrue($db->strictOn);
$this->assertSame([], $db->failover);
$this->assertSame([
'date' => 'Y-m-d',
Expand Down
6 changes: 2 additions & 4 deletions tests/system/Database/Builder/UpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ public function testUpdateBatch(): void
public function testSetUpdateBatchWithoutEscape(): void
{
$builder = new BaseBuilder('jobs', $this->db);
$escape = false;

$builder->setUpdateBatch([
$builder->setData([
[
'id' => 2,
'name' => 'SUBSTRING(name, 1)',
Expand All @@ -266,7 +264,7 @@ public function testSetUpdateBatchWithoutEscape(): void
'name' => 'SUBSTRING(name, 2)',
'description' => 'SUBSTRING(description, 4)',
],
], 'id', $escape);
], false);

$this->db->shouldReturn('execute', new class () {});
$builder->updateBatch(null, 'id');
Expand Down
3 changes: 0 additions & 3 deletions tests/system/Database/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public function testConnectionGroupWithDSN(): void
$this->assertTrue($this->getPrivateProperty($conn, 'pConnect'));
$this->assertSame('latin1', $this->getPrivateProperty($conn, 'charset'));
$this->assertSame('latin1_swedish_ci', $this->getPrivateProperty($conn, 'DBCollat'));
$this->assertTrue($this->getPrivateProperty($conn, 'strictOn'));
$this->assertSame([], $this->getPrivateProperty($conn, 'failover'));
}

Expand All @@ -163,7 +162,6 @@ public function testConnectionGroupWithDSNPostgre(): void
$this->assertFalse($this->getPrivateProperty($conn, 'pConnect'));
$this->assertSame('utf8mb4', $this->getPrivateProperty($conn, 'charset'));
$this->assertSame('utf8mb4_general_ci', $this->getPrivateProperty($conn, 'DBCollat'));
$this->assertTrue($this->getPrivateProperty($conn, 'strictOn'));
$this->assertSame([], $this->getPrivateProperty($conn, 'failover'));
$this->assertSame('5', $this->getPrivateProperty($conn, 'connect_timeout'));
$this->assertSame('1', $this->getPrivateProperty($conn, 'sslmode'));
Expand Down Expand Up @@ -191,7 +189,6 @@ public function testConnectionGroupWithDSNPostgreNative(): void
$this->assertFalse($this->getPrivateProperty($conn, 'pConnect'));
$this->assertSame('utf8mb4', $this->getPrivateProperty($conn, 'charset'));
$this->assertSame('utf8mb4_general_ci', $this->getPrivateProperty($conn, 'DBCollat'));
$this->assertTrue($this->getPrivateProperty($conn, 'strictOn'));
$this->assertSame([], $this->getPrivateProperty($conn, 'failover'));
}

Expand Down
9 changes: 0 additions & 9 deletions tests/system/Database/DatabaseSeederTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use CodeIgniter\Test\CIUnitTestCase;
use Config\Database;
use Faker\Generator;
use PHPUnit\Framework\Attributes\Group;
use Tests\Support\Database\Seeds\SeederWithDBGroup;
use Tests\Support\Database\Seeds\SeederWithoutDBGroup;
Expand Down Expand Up @@ -52,14 +51,6 @@ public function testInstantiateNotDirSeedPath(): void
new Seeder($config);
}

/**
* @TODO remove this when Seeder::faker() is removed
*/
public function testFakerGet(): void
{
$this->assertInstanceOf(Generator::class, Seeder::faker());
}

public function testCallOnEmptySeeder(): void
{
$this->expectException('InvalidArgumentException');
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Database/Live/ForgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function testCreateTableWithNullableFieldsGivesNullDataType(): void

$createTable = self::getPrivateMethodInvoker($this->forge, '_createTable');

$sql = $createTable('forge_nullable_table', false, []);
$sql = $createTable('forge_nullable_table', []);

if ($this->db->DBDriver !== 'SQLSRV') {
// @see https://regex101.com/r/bIHVNw/1
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Database/Live/MySQLi/RawSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function testRawSqlSetUpdateObject(): void
$row->created_at = new RawSql("setDateTime('2022-02-01')");
$data[] = $row;

$this->db->table('user')->setUpdateBatch($data, 'email')->updateBatch(null, 'email');
$this->db->table('user')->setData($data)->updateBatch(null, 'email');

$row->created_at = new RawSql("setDateTime('2022-02-11')");

Expand Down Expand Up @@ -183,7 +183,7 @@ public function testRawSqlSetInsertObject(): void
$row->created_at = new RawSql("setDateTime('2022-06-01')");
$data[] = $row;

$this->db->table('user')->setInsertBatch($data)->insertBatch();
$this->db->table('user')->insertBatch($data);

$this->seeInDatabase('user', ['email' => 'laura@world.com', 'created_at' => '2022-06-01 01:01:11']);
$this->seeInDatabase('user', ['email' => 'travis@world.com', 'created_at' => '2022-06-01 01:01:11']);
Expand Down
13 changes: 13 additions & 0 deletions user_guide_src/source/changelogs/v4.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Method Signature Changes
- The updated method signature is now ``handleRequest(?RouteCollectionInterface $routes, ?Cache $cacheConfig = null)``.
- ``CodeIgniter\CodeIgniter::gatherOutput()`` no longer accepts the deprecated ``$cacheConfig`` parameter.
As this is the first parameter, custom uses of this method will need to be updated to remove the parameter.
- **Database:** The following methods have had their signatures updated to remove deprecated parameters:
- ``CodeIgniter\Database\Forge::_createTable()`` no longer accepts the deprecated ``$ifNotExists`` parameter. The method signature is now ``_createTable(string $table, array $attributes)``.

Removed Deprecated Items
========================
Expand Down Expand Up @@ -70,6 +72,17 @@ Removed Deprecated Items
- ``CodeIgniter\CodeIgniter::determinePath()``
- ``CodeIgniter\CodeIgniter::callExit()``
- ``CodeIgniter\Test\MockCodeIgniter::callExit()``
- **Database:** Removed the following properties and methods deprecated:
- ``CodeIgniter\Database\BaseBuilder::setInsertBatch()``
- ``CodeIgniter\Database\BaseBuilder::setUpdateBatch()``
- ``CodeIgniter\Database\BaseBuilder::cleanClone()``
- ``CodeIgniter\Database\BaseConnection::$strictOn``
- ``CodeIgniter\Database\Forge::$createTableIfStr``
- ``CodeIgniter\Database\Seeder::$faker``
- ``CodeIgniter\Database\Seeder::faker()``
- ``CodeIgniter\Database\OCI8\Forge::$createTableIfStr``
- ``CodeIgniter\Database\OCI8\Forge::getError()``
- ``CodeIgniter\Database\SQLSRV\Forge::$createTableIfStr``
- **Debug:** Removed the following properties and methods deprecated since v4.4.0:
- ``CodeIgniter\Debug\Exceptions::$ob_level``
- ``CodeIgniter\Debug\Exceptions::$viewPath``
Expand Down
2 changes: 1 addition & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 2116 errors
# total 2112 errors

includes:
- argument.type.neon
Expand Down
Loading
Loading