Skip to content

Commit 10adf37

Browse files
committed
Merge branch 'develop' of https://github.com/codeigniter4/CodeIgniter4 into db-underscore
2 parents 180a574 + c925624 commit 10adf37

2 files changed

Lines changed: 32 additions & 16 deletions

File tree

system/Database/BaseConnection.php

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,34 @@ public function getDatabase(): string
514514

515515
//--------------------------------------------------------------------
516516

517+
/**
518+
* Set DB Prefix
519+
*
520+
* Set's the DB Prefix to something new without needing to reconnect
521+
*
522+
* @param string $prefix The prefix
523+
*
524+
* @return string
525+
*/
526+
public function setPrefix(string $prefix = ''): string
527+
{
528+
return $this->DBPrefix = $prefix;
529+
}
530+
531+
//--------------------------------------------------------------------
532+
533+
/**
534+
* Returns the database prefix.
535+
*
536+
* @return string
537+
*/
538+
public function getPrefix(): string
539+
{
540+
return $this->DBPrefix;
541+
}
542+
543+
//--------------------------------------------------------------------
544+
517545
/**
518546
* Returns the last error encountered by this connection.
519547
*
@@ -1329,22 +1357,6 @@ public function prefixTable(string $table = ''): string
13291357

13301358
//--------------------------------------------------------------------
13311359

1332-
/**
1333-
* Set DB Prefix
1334-
*
1335-
* Set's the DB Prefix to something new without needing to reconnect
1336-
*
1337-
* @param string $prefix The prefix
1338-
*
1339-
* @return string
1340-
*/
1341-
public function setPrefix(string $prefix = ''): string
1342-
{
1343-
return $this->DBPrefix = $prefix;
1344-
}
1345-
1346-
//--------------------------------------------------------------------
1347-
13481360
/**
13491361
* Returns the total number of rows affected by this query.
13501362
*

user_guide_src/source/database/queries.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ without needing to create a new connection you can use this method::
7272
$db->setPrefix('newprefix');
7373
$db->prefixTable('tablename'); // outputs newprefix_tablename
7474

75+
You can get the current prefix any time with this method::
76+
77+
$DBPrefix = $db->getPrefix();
78+
7579
**********************
7680
Protecting identifiers
7781
**********************

0 commit comments

Comments
 (0)