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
36 changes: 21 additions & 15 deletions tests/_support/Database/Seeds/CITestSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class CITestSeeder extends Seeder
{
public function run(): void
{
// Job Data
$data = [
'user' => [
[
Expand Down Expand Up @@ -147,7 +146,8 @@ public function run(): void
],
];

// set SQL times to more correct format
// Normalize accepted formats and remove unsupported types per database driver

if ($this->db->DBDriver === 'SQLite3') {
$data['type_test'][0]['type_date'] = '2020/01/11';
$data['type_test'][0]['type_time'] = '15:22:00';
Expand All @@ -157,7 +157,15 @@ public function run(): void

if ($this->db->DBDriver === 'Postgre') {
$data['type_test'][0]['type_time'] = '15:22:00';
$data['type_test'][0]['type_boolean'] = true;
$data['type_test'][0]['type_boolean'] = true; // PostgreSQL has native boolean type

$data['ci_sessions'][] = [
'id' => 'ci_session:1f5o06b43phsnnf8if6bo33b635e4p2o',
'ip_address' => '127.0.0.1',
'timestamp' => '2021-06-25 21:54:14.991403+02',
'data' => '\x' . bin2hex('__ci_last_regenerate|i:1624650854;_ci_previous_url|s:40:\"http://localhost/index.php/home/index\";'),
];

unset(
$data['type_test'][0]['type_enum'],
$data['type_test'][0]['type_set'],
Expand Down Expand Up @@ -185,6 +193,11 @@ public function run(): void
}

if ($this->db->DBDriver === 'MySQLi') {
$data['type_test'][0]['type_time'] = '15:22:00';
$data['type_test'][0]['type_date'] = '2020-01-11';
$data['type_test'][0]['type_datetime'] = '2020-06-18 05:12:24';
$data['type_test'][0]['type_timestamp'] = '2019-07-18 21:53:21';

$data['ci_sessions'][] = [
'id' => 'ci_session:1f5o06b43phsnnf8if6bo33b635e4p2o',
'ip_address' => '127.0.0.1',
Expand All @@ -193,29 +206,22 @@ public function run(): void
];
}

if ($this->db->DBDriver === 'Postgre') {
$data['ci_sessions'][] = [
'id' => 'ci_session:1f5o06b43phsnnf8if6bo33b635e4p2o',
'ip_address' => '127.0.0.1',
'timestamp' => '2021-06-25 21:54:14.991403+02',
'data' => '\x' . bin2hex('__ci_last_regenerate|i:1624650854;_ci_previous_url|s:40:\"http://localhost/index.php/home/index\";'),
];
}

if ($this->db->DBDriver === 'OCI8') {
$this->db->query('alter session set NLS_DATE_FORMAT=?', ['YYYY-MM-DD HH24:MI:SS']);

$data['type_test'][0]['type_date'] = '2020-01-11 22:11:00';
$data['type_test'][0]['type_time'] = '2020-07-18 15:22:00';
$data['type_test'][0]['type_datetime'] = '2020-06-18 05:12:24';
$data['type_test'][0]['type_timestamp'] = '2020-06-18 21:53:21';

unset($data['type_test'][0]['type_blob']);
}

foreach ($data as $table => $dummyData) {
foreach ($data as $table => $seeds) {
$this->db->table($table)->truncate();

foreach ($dummyData as $singleDummyData) {
$this->db->table($table)->insert($singleDummyData);
foreach ($seeds as $seed) {
$this->db->table($table)->insert($seed);
}
}
}
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
Loading
Loading