diff options
Diffstat (limited to 'system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php')
-rw-r--r-- | system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php | 105 |
1 files changed, 34 insertions, 71 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php index 51c70b630..5a492d881 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2015, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,10 +28,10 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) + * @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 - * @link http://codeigniter.com + * @link https://codeigniter.com * @since Version 3.0.0 * @filesource */ @@ -48,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @subpackage Drivers * @category Database * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/database/ + * @link https://codeigniter.com/user_guide/database/ */ class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver { @@ -161,106 +161,69 @@ class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver { // -------------------------------------------------------------------- /** - * Show table query - * - * Generates a platform-specific query string so that the table names can be fetched + * Platform-dependent string escape * - * @param bool $prefix_limit + * @param string * @return string */ - protected function _list_tables($prefix_limit = FALSE) + protected function _escape_str($str) { - $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '".$this->schema."'"; - - if ($prefix_limit !== FALSE && $this->dbprefix !== '') - { - return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' " - .sprintf($this->_like_escape_str, $this->_like_escape_chr); - } - - return $sql; + $this->db->display_error('db_unsupported_feature'); } // -------------------------------------------------------------------- /** - * Show column query + * Determines if a query is a "write" type. * - * Generates a platform-specific query string so that the column names can be fetched - * - * @param string $table - * @return string + * @param string An SQL query string + * @return bool */ - protected function _list_columns($table = '') + public function is_write_type($sql) { - return 'SELECT column_name FROM information_schema.columns WHERE table_name = '.$this->escape($table); - } - - // -------------------------------------------------------------------- + if (preg_match('#^(INSERT|UPDATE).*RETURNING\s.+(\,\s?.+)*$#is', $sql)) + { + return FALSE; + } - /** - * Update statement - * - * Generates a platform-specific update string from the supplied data - * - * @param string $table - * @param array $values - * @return string - */ - protected function _update($table, $values) - { - $this->qb_limit = FALSE; - $this->qb_orderby = array(); - return parent::_update($table, $values); + return parent::is_write_type($sql); } // -------------------------------------------------------------------- /** - * Truncate statement - * - * Generates a platform-specific truncate string from the supplied data + * Show table query * - * If the database does not support the TRUNCATE statement, - * then this method maps to 'DELETE FROM table' + * Generates a platform-specific query string so that the table names can be fetched * - * @param string $table + * @param bool $prefix_limit * @return string */ - protected function _truncate($table) + protected function _list_tables($prefix_limit = FALSE) { - return 'DELETE FROM '.$table; - } + $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '".$this->schema."'"; - // -------------------------------------------------------------------- + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } - /** - * Delete statement - * - * Generates a platform-specific delete string from the supplied data - * - * @param string the table name - * @return string - */ - protected function _delete($table) - { - $this->qb_limit = FALSE; - return parent::_delete($table); + return $sql; } // -------------------------------------------------------------------- /** - * LIMIT + * Show column query * - * Generates a platform-specific LIMIT clause + * Generates a platform-specific query string so that the column names can be fetched * - * @param string $sql SQL Query + * @param string $table * @return string */ - protected function _limit($sql) + protected function _list_columns($table = '') { - return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$this->qb_limit.' ', $sql); + return 'SELECT column_name FROM information_schema.columns WHERE table_name = '.$this->escape($table); } - } |