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
12 changes: 0 additions & 12 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
* @property-read bool $pretend
* @property-read string $queryClass
* @property-read array $reservedIdentifiers
* @property-read bool $strictOn
* @property-read string $subdriver
* @property-read string $swapPre
* @property-read int $transDepth
Expand Down Expand Up @@ -193,17 +192,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
41 changes: 20 additions & 21 deletions system/Database/MySQLi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ class Connection extends BaseConnection
*/
public $foundRows = false;

/**
* Strict SQL mode
*/
protected bool $strictOn = false;

/**
* Connect to the database.
*
Expand Down Expand Up @@ -124,22 +129,19 @@ public function connect(bool $persistent = false)
$this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);
}

// Build init command for strictOn and timezone
$initCommands = [];

if ($this->strictOn !== null) {
if ($this->strictOn) {
$initCommands[] = "sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')";
} else {
$initCommands[] = "sql_mode = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@@sql_mode,
'STRICT_ALL_TABLES,', ''),
',STRICT_ALL_TABLES', ''),
'STRICT_ALL_TABLES', ''),
'STRICT_TRANS_TABLES,', ''),
',STRICT_TRANS_TABLES', ''),
'STRICT_TRANS_TABLES', '')";
}
if ($this->strictOn) {
$initCommands[] = "sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')";
} else {
$initCommands[] = "sql_mode = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@@sql_mode,
'STRICT_ALL_TABLES,', ''),
',STRICT_ALL_TABLES', ''),
'STRICT_ALL_TABLES', ''),
'STRICT_TRANS_TABLES,', ''),
',STRICT_TRANS_TABLES', ''),
'STRICT_TRANS_TABLES', '')";
}

// Set session timezone if configured
Expand All @@ -148,13 +150,10 @@ public function connect(bool $persistent = false)
$initCommands[] = "time_zone = '{$timezoneOffset}'";
}

// Set init command if we have any commands
if ($initCommands !== []) {
$this->mysqli->options(
MYSQLI_INIT_COMMAND,
'SET SESSION ' . implode(', ', $initCommands),
);
}
$this->mysqli->options(
MYSQLI_INIT_COMMAND,
'SET SESSION ' . implode(', ', $initCommands),
);

if (is_array($this->encrypt)) {
$ssl = [];
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 @@ -565,40 +565,6 @@ private function isUniqueConstraintViolation(): bool
return false;
}

/**
* 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
4 changes: 0 additions & 4 deletions tests/_support/Config/Registrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Registrar
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => true, // @todo 4.7.0 to remove in v4.8.0
'failover' => [],
'port' => 5432,
],
Expand All @@ -79,7 +78,6 @@ class Registrar
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => true, // @todo 4.7.0 to remove in v4.8.0
'failover' => [],
'port' => 3306,
'foreignKeys' => true,
Expand All @@ -100,7 +98,6 @@ class Registrar
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => true, // @todo 4.7.0 to remove in v4.8.0
'failover' => [],
'port' => 1433,
],
Expand All @@ -119,7 +116,6 @@ class Registrar
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => true, // @todo 4.7.0 to remove in v4.8.0
'failover' => [],
],
];
Expand Down
3 changes: 0 additions & 3 deletions tests/system/Database/BaseConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ final class BaseConnectionTest extends CIUnitTestCase
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => true,
'failover' => [],
'dateFormat' => [
'date' => 'Y-m-d',
Expand All @@ -64,7 +63,6 @@ final class BaseConnectionTest extends CIUnitTestCase
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => true,
'failover' => [],
];

Expand All @@ -84,7 +82,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
Loading
Loading