From d44812d91d9fbec9c9d742ad759fa08cd405bd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Thu, 16 Feb 2023 23:50:34 +0800 Subject: [PATCH 01/12] Enhance: [MySQLi] use MYSQLI_OPT_INT_AND_FLOAT_NATIVE. --- system/Database/MySQLi/Connection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 094fcfe7e3ec..26ece9a5d44b 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -98,6 +98,7 @@ public function connect(bool $persistent = false) mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX); $this->mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10); + $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1); if (isset($this->strictOn)) { if ($this->strictOn) { From 47833d2b1a55bc3748f8bd818f703f91d6de7c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Fri, 17 Feb 2023 23:11:00 +0800 Subject: [PATCH 02/12] Enhance:[MySQLi] Use the option to define whether MYSQLI_OPT_INT_AND_FLOAT_NATIVE needs to be used. --- app/Config/Database.php | 35 ++++++++++++++------------- system/Database/BaseConnection.php | 8 ++++++ system/Database/MySQLi/Connection.php | 5 +++- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/app/Config/Database.php b/app/Config/Database.php index 2c092124550f..44515c4d5ecc 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -25,23 +25,24 @@ class Database extends Config * The default database connection. */ public array $default = [ - 'DSN' => '', - 'hostname' => 'localhost', - 'username' => '', - 'password' => '', - 'database' => '', - 'DBDriver' => 'MySQLi', - 'DBPrefix' => '', - 'pConnect' => false, - 'DBDebug' => true, - 'charset' => 'utf8', - 'DBCollat' => 'utf8_general_ci', - 'swapPre' => '', - 'encrypt' => false, - 'compress' => false, - 'strictOn' => false, - 'failover' => [], - 'port' => 3306, + 'DSN' => '', + 'hostname' => 'localhost', + 'username' => '', + 'password' => '', + 'database' => '', + 'DBDriver' => 'MySQLi', + 'DBPrefix' => '', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + 'DBTypeNative' => false, ]; /** diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index badd34d5c077..5d79c8c052eb 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -29,6 +29,7 @@ * @property string $DBDriver * @property string $DBPrefix * @property string $DSN + * @property bool $DBTypeNative * @property array|bool $encrypt * @property array $failover * @property string $hostname @@ -339,6 +340,13 @@ abstract class BaseConnection implements ConnectionInterface */ protected $queryClass = Query::class; + /** + * Use MYSQLI_OPT_INT_AND_FLOAT_NATIVE + * + * @var bool + */ + protected $DBTypeNative = false; + /** * Saves our connection settings. */ diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 26ece9a5d44b..f6cbe83dd604 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -98,7 +98,10 @@ public function connect(bool $persistent = false) mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX); $this->mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10); - $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1); + + if(isset($this->DBTypeNative) && $this->DBTypeNative){ + $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE,1); + } if (isset($this->strictOn)) { if ($this->strictOn) { From be1eab9c4f39b2bf3e826b55ec744a7ff23463ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sat, 18 Feb 2023 21:42:57 +0800 Subject: [PATCH 03/12] fix:Rename the DBTypeNative to numberNative and move the property to MySQLi for use. --- app/Config/Database.php | 2 +- system/Database/BaseConnection.php | 8 -------- system/Database/MySQLi/Connection.php | 11 +++++++++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/Config/Database.php b/app/Config/Database.php index 44515c4d5ecc..e2450ec16cf1 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -42,7 +42,7 @@ class Database extends Config 'strictOn' => false, 'failover' => [], 'port' => 3306, - 'DBTypeNative' => false, + 'numberNative' => false, ]; /** diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 5d79c8c052eb..badd34d5c077 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -29,7 +29,6 @@ * @property string $DBDriver * @property string $DBPrefix * @property string $DSN - * @property bool $DBTypeNative * @property array|bool $encrypt * @property array $failover * @property string $hostname @@ -340,13 +339,6 @@ abstract class BaseConnection implements ConnectionInterface */ protected $queryClass = Query::class; - /** - * Use MYSQLI_OPT_INT_AND_FLOAT_NATIVE - * - * @var bool - */ - protected $DBTypeNative = false; - /** * Saves our connection settings. */ diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index f6cbe83dd604..f657734c896a 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -72,6 +72,13 @@ class Connection extends BaseConnection */ public $resultMode = MYSQLI_STORE_RESULT; + /** + * Use MYSQLI_OPT_INT_AND_FLOAT_NATIVE + * + * @var bool + */ + public $numberNative = false; + /** * Connect to the database. * @@ -99,8 +106,8 @@ public function connect(bool $persistent = false) $this->mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10); - if(isset($this->DBTypeNative) && $this->DBTypeNative){ - $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE,1); + if (isset($this->numberNative) && $this->numberNative) { + $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1); } if (isset($this->strictOn)) { From 7b756d1fbb1e18d814474d521ed16f43b3f70dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sat, 18 Feb 2023 22:34:03 +0800 Subject: [PATCH 04/12] Enhance:Add numberNative to configuration.rst to specify whether MYSQLI_OPT_INT_AND_FLOAT_NATIVE is enabled or not. --- user_guide_src/source/database/configuration.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index b5a768439ccc..33a069800d29 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -150,6 +150,7 @@ Explanation of Values: See `SQLite documentation `_. To enforce Foreign Key constraint, set this config item to true. **busyTimeout** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only). +**numberNative** true/false (boolean) - Whether or not to enable MYSQLI_OPT_INT_AND_FLOAT_NATIVE (``MySQLi`` only). =============== =========================================================================================================== .. note:: Depending on what database driver you are using (``MySQLi``, ``Postgres``, From 4ff2ffea507ad84d4c549b13b7add21553faf579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sat, 18 Feb 2023 22:39:13 +0800 Subject: [PATCH 05/12] fix:Configuration.rst typesetting corrections. --- .../source/database/configuration.rst | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 33a069800d29..0c16803d7164 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -108,50 +108,50 @@ default group's configuration settings. The values should be name following this Explanation of Values: ********************** -=============== =========================================================================================================== - Name Config Description -=============== =========================================================================================================== -**dsn** The DSN connect string (an all-in-one configuration sequence). -**hostname** The hostname of your database server. Often this is 'localhost'. -**username** The username used to connect to the database. (``SQLite3`` does not use this.) -**password** The password used to connect to the database. (``SQLite3`` does not use this.) -**database** The name of the database you want to connect to. - - .. note:: CodeIgniter doesn't support dots (``.``) in the database, table, and column names. -**DBDriver** The database driver name. e.g.,: ``MySQLi``, ``Postgres``, etc. The case must match the driver name. - You can set a fully qualified classname to use your custom driver. -**DBPrefix** An optional table prefix which will added to the table name when running - :doc:`Query Builder ` queries. This permits multiple CodeIgniter - installations to share one database. -**pConnect** true/false (boolean) - Whether to use a persistent connection. -**DBDebug** true/false (boolean) - Whether to throw exceptions or not when database errors occur. -**charset** The character set used in communicating with the database. -**DBCollat** The character collation used in communicating with the database (``MySQLi`` only). -**swapPre** A default table prefix that should be swapped with ``DBPrefix``. This is useful for distributed - applications where you might run manually written queries, and need the prefix to still be - customizable by the end user. -**schema** The database schema, default value varies by driver. (Used by ``Postgres`` and ``SQLSRV``.) -**encrypt** Whether or not to use an encrypted connection. - ``SQLSRV`` driver accepts true/false - ``MySQLi`` driver accepts an array with the following options: - * ``ssl_key`` - Path to the private key file - * ``ssl_cert`` - Path to the public key certificate file - * ``ssl_ca`` - Path to the certificate authority file - * ``ssl_capath`` - Path to a directory containing trusted CA certificates in PEM format - * ``ssl_cipher`` - List of *allowed* ciphers to be used for the encryption, separated by colons (``:``) - * ``ssl_verify`` - true/false; Whether to verify the server certificate or not (``MySQLi`` only) -**compress** Whether or not to use client compression (``MySQLi`` only). -**strictOn** true/false (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL - while developing an application (``MySQLi`` only). -**port** The database port number. -**foreignKeys** true/false (boolean) - Whether or not to enable Foreign Key constraint (``SQLite3`` only). - - .. important:: SQLite3 Foreign Key constraint is disabled by default. - See `SQLite documentation `_. - To enforce Foreign Key constraint, set this config item to true. -**busyTimeout** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only). +=============== =========================================================================================================== + Name Config Description +=============== =========================================================================================================== +**dsn** The DSN connect string (an all-in-one configuration sequence). +**hostname** The hostname of your database server. Often this is 'localhost'. +**username** The username used to connect to the database. (``SQLite3`` does not use this.) +**password** The password used to connect to the database. (``SQLite3`` does not use this.) +**database** The name of the database you want to connect to. + + .. note:: CodeIgniter doesn't support dots (``.``) in the database, table, and column names. +**DBDriver** The database driver name. e.g.,: ``MySQLi``, ``Postgres``, etc. The case must match the driver name. + You can set a fully qualified classname to use your custom driver. +**DBPrefix** An optional table prefix which will added to the table name when running + :doc:`Query Builder ` queries. This permits multiple CodeIgniter + installations to share one database. +**pConnect** true/false (boolean) - Whether to use a persistent connection. +**DBDebug** true/false (boolean) - Whether to throw exceptions or not when database errors occur. +**charset** The character set used in communicating with the database. +**DBCollat** The character collation used in communicating with the database (``MySQLi`` only). +**swapPre** A default table prefix that should be swapped with ``DBPrefix``. This is useful for distributed + applications where you might run manually written queries, and need the prefix to still be + customizable by the end user. +**schema** The database schema, default value varies by driver. (Used by ``Postgres`` and ``SQLSRV``.) +**encrypt** Whether or not to use an encrypted connection. + ``SQLSRV`` driver accepts true/false + ``MySQLi`` driver accepts an array with the following options: + * ``ssl_key`` - Path to the private key file + * ``ssl_cert`` - Path to the public key certificate file + * ``ssl_ca`` - Path to the certificate authority file + * ``ssl_capath`` - Path to a directory containing trusted CA certificates in PEM format + * ``ssl_cipher`` - List of *allowed* ciphers to be used for the encryption, separated by colons (``:``) + * ``ssl_verify`` - true/false; Whether to verify the server certificate or not (``MySQLi`` only) +**compress** Whether or not to use client compression (``MySQLi`` only). +**strictOn** true/false (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL + while developing an application (``MySQLi`` only). +**port** The database port number. +**foreignKeys** true/false (boolean) - Whether or not to enable Foreign Key constraint (``SQLite3`` only). + + .. important:: SQLite3 Foreign Key constraint is disabled by default. + See `SQLite documentation `_. + To enforce Foreign Key constraint, set this config item to true. +**busyTimeout** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only). **numberNative** true/false (boolean) - Whether or not to enable MYSQLI_OPT_INT_AND_FLOAT_NATIVE (``MySQLi`` only). -=============== =========================================================================================================== +=============== =========================================================================================================== .. note:: Depending on what database driver you are using (``MySQLi``, ``Postgres``, etc.) not all values will be needed. For example, when using ``SQLite3`` you From d017a0b6c5cd27da4cd1d01ac43861067dc0025e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sat, 18 Feb 2023 23:39:37 +0800 Subject: [PATCH 06/12] Enhance:Add and complete test files for NumberNative. --- app/Config/Database.php | 39 ++++---- .../Database/Live/MySQLi/NumberNativeTest.php | 88 +++++++++++++++++++ 2 files changed, 108 insertions(+), 19 deletions(-) create mode 100644 tests/system/Database/Live/MySQLi/NumberNativeTest.php diff --git a/app/Config/Database.php b/app/Config/Database.php index e2450ec16cf1..9e752027feed 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -50,25 +50,26 @@ class Database extends Config * running PHPUnit database tests. */ public array $tests = [ - 'DSN' => '', - 'hostname' => '127.0.0.1', - 'username' => '', - 'password' => '', - 'database' => ':memory:', - 'DBDriver' => 'SQLite3', - 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS - 'pConnect' => false, - 'DBDebug' => true, - 'charset' => 'utf8', - 'DBCollat' => 'utf8_general_ci', - 'swapPre' => '', - 'encrypt' => false, - 'compress' => false, - 'strictOn' => false, - 'failover' => [], - 'port' => 3306, - 'foreignKeys' => true, - 'busyTimeout' => 1000, + 'DSN' => '', + 'hostname' => '127.0.0.1', + 'username' => '', + 'password' => '', + 'database' => ':memory:', + 'DBDriver' => 'SQLite3', + 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + 'foreignKeys' => true, + 'busyTimeout' => 1000, + 'numberNative' => false, ]; public function __construct() diff --git a/tests/system/Database/Live/MySQLi/NumberNativeTest.php b/tests/system/Database/Live/MySQLi/NumberNativeTest.php new file mode 100644 index 000000000000..eb2608b5c751 --- /dev/null +++ b/tests/system/Database/Live/MySQLi/NumberNativeTest.php @@ -0,0 +1,88 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace CodeIgniter\Database\Live\MySQLi; + +use CodeIgniter\Test\CIUnitTestCase; +use CodeIgniter\Test\DatabaseTestTrait; +use Config\Database; +use Tests\Support\Database\Seeds\CITestSeeder; + +/** + * @group DatabaseLive + * + * @internal + */ +final class NumberNativeTest extends CIUnitTestCase +{ + use DatabaseTestTrait; + + private $tests; + protected $refresh = true; + protected $seed = CITestSeeder::class; + + protected function setUp(): void + { + parent::setUp(); + + $config = config('Database'); + + $this->tests = $config->tests; + + $this->tests['DBDriver'] = 'MySQLi'; + } + + public function testEnableNumberNative() + { + $this->tests['numberNative'] = true; + + $db1 = Database::connect($this->tests); + + $this->assertTrue($db1->numberNative); + } + + public function testDisableNumberNative() + { + $this->tests['numberNative'] = false; + + $db1 = Database::connect($this->tests); + + $this->assertFalse($db1->numberNative); + } + + public function testQueryDataAfterEnableNumberNative() + { + $this->tests['numberNative'] = true; + + $db1 = Database::connect($this->tests); + + $data = $db1->table('db_type_test') + ->get() + ->getRow(); + + $this->assertIsFloat($data->type_float); + $this->assertIsInt($data->type_integer); + } + + public function testQueryDataAfterDisableNumberNative() + { + $this->tests['numberNative'] = false; + + $db1 = Database::connect($this->tests); + + $data = $db1->table('db_type_test') + ->get() + ->getRow(); + + $this->assertIsString($data->type_float); + $this->assertIsString($data->type_integer); + } +} From 1cd3415c00af19e441d9a43d31e40562f0255b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sun, 19 Feb 2023 12:47:08 +0800 Subject: [PATCH 07/12] fix:NumberNativeTest.php adds DBDriver's judgment test and fixes MySQLi's isset judgment for numberNative. --- system/Database/MySQLi/Connection.php | 4 ++-- .../Database/Live/MySQLi/NumberNativeTest.php | 18 ++++++++++++++++-- .../source/database/configuration.rst | 8 ++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index f657734c896a..00c165dbef51 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -106,8 +106,8 @@ public function connect(bool $persistent = false) $this->mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10); - if (isset($this->numberNative) && $this->numberNative) { - $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1); + if($this->numberNative === true){ + $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE,1); } if (isset($this->strictOn)) { diff --git a/tests/system/Database/Live/MySQLi/NumberNativeTest.php b/tests/system/Database/Live/MySQLi/NumberNativeTest.php index eb2608b5c751..1f95dd4e7c59 100644 --- a/tests/system/Database/Live/MySQLi/NumberNativeTest.php +++ b/tests/system/Database/Live/MySQLi/NumberNativeTest.php @@ -36,8 +36,6 @@ protected function setUp(): void $config = config('Database'); $this->tests = $config->tests; - - $this->tests['DBDriver'] = 'MySQLi'; } public function testEnableNumberNative() @@ -46,6 +44,10 @@ public function testEnableNumberNative() $db1 = Database::connect($this->tests); + if ($db1->DBDriver !== 'MySQLi') { + $this->markTestSkipped('Only MySQLi can complete this test.'); + } + $this->assertTrue($db1->numberNative); } @@ -55,6 +57,10 @@ public function testDisableNumberNative() $db1 = Database::connect($this->tests); + if ($db1->DBDriver !== 'MySQLi') { + $this->markTestSkipped('Only MySQLi can complete this test.'); + } + $this->assertFalse($db1->numberNative); } @@ -64,6 +70,10 @@ public function testQueryDataAfterEnableNumberNative() $db1 = Database::connect($this->tests); + if ($db1->DBDriver !== 'MySQLi') { + $this->markTestSkipped('Only MySQLi can complete this test.'); + } + $data = $db1->table('db_type_test') ->get() ->getRow(); @@ -78,6 +88,10 @@ public function testQueryDataAfterDisableNumberNative() $db1 = Database::connect($this->tests); + if ($db1->DBDriver !== 'MySQLi') { + $this->markTestSkipped('Only MySQLi can complete this test.'); + } + $data = $db1->table('db_type_test') ->get() ->getRow(); diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 0c16803d7164..7da92aac9139 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -108,9 +108,9 @@ default group's configuration settings. The values should be name following this Explanation of Values: ********************** -=============== =========================================================================================================== +================ =========================================================================================================== Name Config Description -=============== =========================================================================================================== +================ =========================================================================================================== **dsn** The DSN connect string (an all-in-one configuration sequence). **hostname** The hostname of your database server. Often this is 'localhost'. **username** The username used to connect to the database. (``SQLite3`` does not use this.) @@ -150,8 +150,8 @@ Explanation of Values: See `SQLite documentation `_. To enforce Foreign Key constraint, set this config item to true. **busyTimeout** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only). -**numberNative** true/false (boolean) - Whether or not to enable MYSQLI_OPT_INT_AND_FLOAT_NATIVE (``MySQLi`` only). -=============== =========================================================================================================== +**numberNative** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only). +================ =========================================================================================================== .. note:: Depending on what database driver you are using (``MySQLi``, ``Postgres``, etc.) not all values will be needed. For example, when using ``SQLite3`` you From 7b152dfbd85aecbb60e451d585aa52eb0f81add7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sun, 19 Feb 2023 12:49:51 +0800 Subject: [PATCH 08/12] fix:Column description of numberNative in CodeIgniter4/user_guide_src/source/database/configuration.rst. --- user_guide_src/source/database/configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 7da92aac9139..1683ce801518 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -150,7 +150,7 @@ Explanation of Values: See `SQLite documentation `_. To enforce Foreign Key constraint, set this config item to true. **busyTimeout** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only). -**numberNative** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only). +**numberNative** true/false (boolean) - Whether or not to enable MYSQLI_OPT_INT_AND_FLOAT_NATIVE (``MySQLi`` only). ================ =========================================================================================================== .. note:: Depending on what database driver you are using (``MySQLi``, ``Postgres``, From c18581dd0eec72cd018a68abc6f5a72cf0cd0a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sun, 19 Feb 2023 13:37:01 +0800 Subject: [PATCH 09/12] fix:Run composer cs-fix and modify the Enhancements/DataBase description in user_guide_src/source/changelogs/v4.4.0.rst. --- system/Database/MySQLi/Connection.php | 6 +++--- user_guide_src/source/changelogs/v4.4.0.rst | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 00c165dbef51..45b306ce2a44 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -105,9 +105,9 @@ public function connect(bool $persistent = false) mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX); $this->mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10); - - if($this->numberNative === true){ - $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE,1); + + if ($this->numberNative === true) { + $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1); } if (isset($this->strictOn)) { diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index a4d2afbafec2..8844656b91dd 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -59,6 +59,9 @@ Forge Others ------ +- **numberNative:** Added the ``numberNative`` attribute to the Database setting to keep the variable type obtained after SQL Query consistent with the type set in the DataBase. + See `configuration.rst`_ for details. + Model ===== From b2c74e8b7d3d6425abb918747a0cad0191a2e871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sun, 19 Feb 2023 13:48:48 +0800 Subject: [PATCH 10/12] fix:Modify the Enhancements/DataBase description in user_guide_src/source/changelogs/v4.4.0.rst. --- user_guide_src/source/changelogs/v4.4.0.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index 8844656b91dd..959dc75bdd87 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -59,8 +59,9 @@ Forge Others ------ -- **numberNative:** Added the ``numberNative`` attribute to the Database setting to keep the variable type obtained after SQL Query consistent with the type set in the DataBase. - See `configuration.rst`_ for details. +- **Database:** Added the ``numberNative`` attribute to the Database Config for MySQLi to keep the variable type obtained after SQL Query consistent with the type set in the database. + See `configuration.rst `_ + for details. Model ===== From 78ff0a9775f19a0ed0af84209ae3d295c4c9b205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sun, 19 Feb 2023 14:19:49 +0800 Subject: [PATCH 11/12] fix:Modify database/configuration.rst and changelogs/v4.4.0.rst description. --- user_guide_src/source/changelogs/v4.4.0.rst | 3 +-- user_guide_src/source/database/configuration.rst | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index 959dc75bdd87..8d3cc6894dfc 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -60,8 +60,7 @@ Others ------ - **Database:** Added the ``numberNative`` attribute to the Database Config for MySQLi to keep the variable type obtained after SQL Query consistent with the type set in the database. - See `configuration.rst `_ - for details. + See :ref:`Database Configuration `. Model ===== diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 1683ce801518..cfd666988ac3 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -104,6 +104,8 @@ default group's configuration settings. The values should be name following this database.default.password = ''; database.default.database = 'ci4'; +.. _database-configuration-explanation-of-values: + ********************** Explanation of Values: ********************** From 0a8c9711597c7bc88de429e72b30a5285ecbc4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Sun, 19 Feb 2023 14:41:18 +0800 Subject: [PATCH 12/12] fix:Modify changelogs/v4.4.0.rst description and remove the numberNative attribute from the $test array in app/Config/Database.php --- app/Config/Database.php | 39 ++++++++++----------- user_guide_src/source/changelogs/v4.4.0.rst | 2 +- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/app/Config/Database.php b/app/Config/Database.php index 9e752027feed..e2450ec16cf1 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -50,26 +50,25 @@ class Database extends Config * running PHPUnit database tests. */ public array $tests = [ - 'DSN' => '', - 'hostname' => '127.0.0.1', - 'username' => '', - 'password' => '', - 'database' => ':memory:', - 'DBDriver' => 'SQLite3', - 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS - 'pConnect' => false, - 'DBDebug' => true, - 'charset' => 'utf8', - 'DBCollat' => 'utf8_general_ci', - 'swapPre' => '', - 'encrypt' => false, - 'compress' => false, - 'strictOn' => false, - 'failover' => [], - 'port' => 3306, - 'foreignKeys' => true, - 'busyTimeout' => 1000, - 'numberNative' => false, + 'DSN' => '', + 'hostname' => '127.0.0.1', + 'username' => '', + 'password' => '', + 'database' => ':memory:', + 'DBDriver' => 'SQLite3', + 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + 'foreignKeys' => true, + 'busyTimeout' => 1000, ]; public function __construct() diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index 8d3cc6894dfc..24ef1efc1707 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -59,7 +59,7 @@ Forge Others ------ -- **Database:** Added the ``numberNative`` attribute to the Database Config for MySQLi to keep the variable type obtained after SQL Query consistent with the type set in the database. +- **MySQLi:** Added the ``numberNative`` attribute to the Database Config to keep the variable type obtained after SQL Query consistent with the type set in the database. See :ref:`Database Configuration `. Model