summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/cubrid
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-25 14:21:41 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-25 14:21:41 +0100
commit2e171023bae38735ec08bbd9cb160cee75edbc62 (patch)
tree15327555ec2101f723f6ae35c6c388abf1b18317 /system/database/drivers/cubrid
parente7d017bcc38909f55e8f817b27263e59d1ca5598 (diff)
Make db_pconnect an alias for db_connect(TRUE) and reduce code repetition
Diffstat (limited to 'system/database/drivers/cubrid')
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php56
1 files changed, 9 insertions, 47 deletions
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 0db51735c..2e79faa39 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -102,61 +102,23 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @return resource
- */
- public function db_connect()
- {
- return $this->_cubrid_connect();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * In CUBRID persistent DB connection is supported natively in CUBRID
- * engine which can be configured in the CUBRID Broker configuration
- * file by setting the CCI_PCONNECT parameter to ON. In that case, all
- * connections established between the client application and the
- * server will become persistent.
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return $this->_cubrid_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * CUBRID connection
- *
- * A CUBRID-specific method to create a connection to the database.
- * Except for determining if a persistent connection should be used,
- * the rest of the logic is the same for db_connect() and db_pconnect().
- *
* @param bool $persistent
* @return resource
*/
- protected function _cubrid_connect($persistent = FALSE)
+ public function db_connect($persistent = FALSE)
{
if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
{
- $_temp = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
- $conn_id = ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
- ? $_temp($this->dsn, $this->username, $this->password)
- : $_temp($this->dsn);
- }
- else
- {
- $_temp = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
- $conn_id = ($this->username !== '')
- ? $_temp($this->hostname, $this->port, $this->database, $this->username, $this->password)
- : $_temp($this->hostname, $this->port, $this->database);
+ $func = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
+ return ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
+ ? $func($this->dsn, $this->username, $this->password)
+ : $func($this->dsn);
}
- return $conn_id;
+ $func = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
+ return ($this->username !== '')
+ ? $func($this->hostname, $this->port, $this->database, $this->username, $this->password)
+ : $func($this->hostname, $this->port, $this->database);
}
// --------------------------------------------------------------------