Update database and helper functionality in CodeIgniter
Revised database drivers, query builder, and file/inflector helpers for improved consistency and functionality. Updated copyrights, links, and standardized function names including deprecating `is_countable` in favor of `word_is_countable`. Added support for new SQL features and optimized query handling.
This commit is contained in:
Executable → Regular
+15
-24
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
* Copyright (c) 2019 - 2022, CodeIgniter Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,9 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @copyright Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.3.0
|
||||
* @filesource
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_postgre_driver extends CI_DB {
|
||||
|
||||
@@ -78,22 +79,12 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
* Build DSN
|
||||
*
|
||||
* Creates a DSN string to be used for db_connect() and db_pconnect()
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($params)
|
||||
protected function _build_dsn()
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
if ( ! empty($this->dsn))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dsn === '' OR $this->dsn = '';
|
||||
|
||||
if (strpos($this->hostname, '/') !== FALSE)
|
||||
@@ -145,10 +136,11 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
* Database connection
|
||||
*
|
||||
* @param bool $persistent
|
||||
* @return resource
|
||||
* @return resource|object
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
empty($this->dsn) && $this->_build_dsn();
|
||||
$this->conn_id = ($persistent === TRUE)
|
||||
? pg_pconnect($this->dsn)
|
||||
: pg_connect($this->dsn);
|
||||
@@ -224,8 +216,8 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
* and so we'll have to fall back to running a query in
|
||||
* order to get it.
|
||||
*/
|
||||
return isset($pg_version['server'])
|
||||
? $this->data_cache['version'] = $pg_version['server']
|
||||
return (isset($pg_version['server']) && preg_match('#^(\d+\.\d+)#', $pg_version['server'], $match))
|
||||
? $this->data_cache['version'] = $match[1]
|
||||
: parent::version();
|
||||
}
|
||||
|
||||
@@ -235,7 +227,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
* Execute the query
|
||||
*
|
||||
* @param string $sql an SQL query
|
||||
* @return resource
|
||||
* @return resource|object
|
||||
*/
|
||||
protected function _execute($sql)
|
||||
{
|
||||
@@ -354,8 +346,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
*/
|
||||
public function insert_id()
|
||||
{
|
||||
$v = pg_version($this->conn_id);
|
||||
$v = isset($v['server']) ? $v['server'] : 0; // 'server' key is only available since PosgreSQL 7.4
|
||||
$v = $this->version();
|
||||
|
||||
$table = (func_num_args() > 0) ? func_get_arg(0) : NULL;
|
||||
$column = (func_num_args() > 1) ? func_get_arg(1) : NULL;
|
||||
@@ -429,7 +420,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
{
|
||||
return 'SELECT "column_name"
|
||||
FROM "information_schema"."columns"
|
||||
WHERE LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
WHERE "table_schema" = \''.$this->schema.'\' AND LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -444,7 +435,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
{
|
||||
$sql = 'SELECT "column_name", "data_type", "character_maximum_length", "numeric_precision", "column_default"
|
||||
FROM "information_schema"."columns"
|
||||
WHERE LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
WHERE "table_schema" = \''.$this->schema.'\' AND LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
|
||||
if (($query = $this->query($sql)) === FALSE)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user