Skip to content

Commit ec40207

Browse files
committed
fix $tableName = null
1 parent 843ff52 commit ec40207

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

system/Database/BaseConnection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,11 +1604,11 @@ abstract public function insertID();
16041604
/**
16051605
* Generates the SQL for listing tables in a platform-dependent manner.
16061606
*
1607-
* @param string $tableName If $tableName is provided will return only this table if exists.
1607+
* @param null|string $tableName If $tableName is provided will return only this table if exists.
16081608
*
16091609
* @return false|string
16101610
*/
1611-
abstract protected function _listTables(bool $constrainByPrefix = false, string $tableName = '');
1611+
abstract protected function _listTables(bool $constrainByPrefix = false, ?string $tableName = null);
16121612

16131613
/**
16141614
* Generates a platform-specific query string so that the column names can be fetched.

system/Database/MySQLi/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ public function escapeLikeStringDirect($str)
369369
* Generates the SQL for listing tables in a platform-dependent manner.
370370
* Uses escapeLikeStringDirect().
371371
*
372-
* @param string $tableName If $tableName is provided will return only this table if exists.
372+
* @param null|string $tableName If $tableName is provided will return only this table if exists.
373373
*/
374-
protected function _listTables(bool $prefixLimit = false, string $tableName = ''): string
374+
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
375375
{
376376
$sql = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->database);
377377

378-
if (! empty($tableName)) {
378+
if ($tableName !== null) {
379379
return $sql . ' LIKE ' . $this->escape($tableName);
380380
}
381381

system/Database/OCI8/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ public function affectedRows(): int
243243
/**
244244
* Generates the SQL for listing tables in a platform-dependent manner.
245245
*
246-
* @param string $tableName If $tableName is provided will return only this table if exists.
246+
* @param null|string $tableName If $tableName is provided will return only this table if exists.
247247
*/
248-
protected function _listTables(bool $prefixLimit = false, string $tableName = ''): string
248+
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
249249
{
250250
$sql = 'SELECT "TABLE_NAME" FROM "USER_TABLES"';
251251

252-
if (! empty($tableName)) {
252+
if ($tableName !== null) {
253253
return $sql . ' WHERE "TABLE_NAME" LIKE ' . $this->escape($tableName);
254254
}
255255

system/Database/Postgre/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ protected function _escapeString(string $str): string
205205
/**
206206
* Generates the SQL for listing tables in a platform-dependent manner.
207207
*
208-
* @param string $tableName If $tableName is provided will return only this table if exists.
208+
* @param null|string $tableName If $tableName is provided will return only this table if exists.
209209
*/
210-
protected function _listTables(bool $prefixLimit = false, string $tableName = ''): string
210+
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
211211
{
212212
$sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \'' . $this->schema . "'";
213213

214-
if (! empty($tableName)) {
214+
if ($tableName !== null) {
215215
return $sql . ' AND "table_name" LIKE ' . $this->escape($tableName);
216216
}
217217

system/Database/SQLSRV/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,16 @@ public function insertID(): int
184184
/**
185185
* Generates the SQL for listing tables in a platform-dependent manner.
186186
*
187-
* @param string $tableName If $tableName is provided will return only this table if exists.
187+
* @param null|string $tableName If $tableName is provided will return only this table if exists.
188188
*/
189-
protected function _listTables(bool $prefixLimit = false, string $tableName = ''): string
189+
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
190190
{
191191
$sql = 'SELECT [TABLE_NAME] AS "name"'
192192
. ' FROM [INFORMATION_SCHEMA].[TABLES] '
193193
. ' WHERE '
194194
. " [TABLE_SCHEMA] = '" . $this->schema . "' ";
195195

196-
if (! empty($tableName)) {
196+
if ($tableName !== null) {
197197
return $sql .= ' AND [TABLE_NAME] LIKE ' . $this->escape($tableName);
198198
}
199199

system/Database/SQLite3/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ protected function _escapeString(string $str): string
161161
/**
162162
* Generates the SQL for listing tables in a platform-dependent manner.
163163
*
164-
* @param string $tableName If $tableName is provided will return only this table if exists.
164+
* @param null|string $tableName If $tableName is provided will return only this table if exists.
165165
*/
166-
protected function _listTables(bool $prefixLimit = false, string $tableName = ''): string
166+
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
167167
{
168-
if (! empty($tableName)) {
168+
if ($tableName !== null) {
169169
return 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\''
170170
. ' AND "NAME" NOT LIKE \'sqlite!_%\' ESCAPE \'!\''
171171
. ' AND "NAME" LIKE ' . $this->escape($tableName);

system/Test/Mock/MockConnection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ public function insertID(): int
180180
/**
181181
* Generates the SQL for listing tables in a platform-dependent manner.
182182
*
183-
* @param string $tableName If $tableName is provided will return only this table if exists.
183+
* @param null|string $tableName If $tableName is provided will return only this table if exists.
184184
*/
185-
protected function _listTables(bool $constrainByPrefix = false, string $tableName = ''): string
185+
protected function _listTables(bool $constrainByPrefix = false, ?string $tableName = null): string
186186
{
187187
return '';
188188
}

0 commit comments

Comments
 (0)