Subversion-Projekte lars-tiefland.ci

Revision

Revision 2257 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
68 lars 1
<?php
2
/**
3
 * CodeIgniter
4
 *
5
 * An open source application development framework for PHP
6
 *
7
 * This content is released under the MIT License (MIT)
8
 *
2414 lars 9
 * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
68 lars 10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
12
 * of this software and associated documentation files (the "Software"), to deal
13
 * in the Software without restriction, including without limitation the rights
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
 * copies of the Software, and to permit persons to whom the Software is
16
 * furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included in
19
 * all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
 * THE SOFTWARE.
28
 *
29
 * @package	CodeIgniter
30
 * @author	EllisLab Dev Team
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
2414 lars 32
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
 * @license	https://opensource.org/licenses/MIT	MIT License
68 lars 34
 * @link	https://codeigniter.com
35
 * @since	Version 3.0.0
36
 * @filesource
37
 */
38
defined('BASEPATH') OR exit('No direct script access allowed');
39
 
40
/**
41
 * PDO 4D Database Adapter Class
42
 *
43
 * Note: _DB is an extender class that the app controller
44
 * creates dynamically based on whether the query builder
45
 * class is being used or not.
46
 *
47
 * @package		CodeIgniter
48
 * @subpackage	Drivers
49
 * @category	Database
50
 * @author		EllisLab Dev Team
51
 * @link		https://codeigniter.com/user_guide/database/
52
 */
53
class CI_DB_pdo_4d_driver extends CI_DB_pdo_driver {
54
 
55
	/**
56
	 * Sub-driver
57
	 *
58
	 * @var	string
59
	 */
60
	public $subdriver = '4d';
61
 
62
	/**
63
	 * Identifier escape character
64
	 *
65
	 * @var	string[]
66
	 */
67
	protected $_escape_char = array('[', ']');
68
 
69
	// --------------------------------------------------------------------
70
 
71
	/**
72
	 * Class constructor
73
	 *
74
	 * Builds the DSN if not already set.
75
	 *
76
	 * @param	array	$params
77
	 * @return	void
78
	 */
79
	public function __construct($params)
80
	{
81
		parent::__construct($params);
82
 
83
		if (empty($this->dsn))
84
		{
85
			$this->dsn = '4D:host='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname);
86
 
87
			empty($this->port) OR $this->dsn .= ';port='.$this->port;
88
			empty($this->database) OR $this->dsn .= ';dbname='.$this->database;
89
			empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set;
90
		}
91
		elseif ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 3) === FALSE)
92
		{
93
			$this->dsn .= ';charset='.$this->char_set;
94
		}
95
	}
96
 
97
	// --------------------------------------------------------------------
98
 
99
	/**
100
	 * Show table query
101
	 *
102
	 * Generates a platform-specific query string so that the table names can be fetched
103
	 *
104
	 * @param	bool	$prefix_limit
105
	 * @return	string
106
	 */
107
	protected function _list_tables($prefix_limit = FALSE)
108
	{
109
		$sql = 'SELECT '.$this->escape_identifiers('TABLE_NAME').' FROM '.$this->escape_identifiers('_USER_TABLES');
110
 
111
		if ($prefix_limit === TRUE && $this->dbprefix !== '')
112
		{
113
			$sql .= ' WHERE '.$this->escape_identifiers('TABLE_NAME')." LIKE '".$this->escape_like_str($this->dbprefix)."%' "
114
				.sprintf($this->_like_escape_str, $this->_like_escape_chr);
115
		}
116
 
117
		return $sql;
118
	}
119
 
120
	// --------------------------------------------------------------------
121
 
122
	/**
123
	 * Show column query
124
	 *
125
	 * Generates a platform-specific query string so that the column names can be fetched
126
	 *
127
	 * @param	string	$table
128
	 * @return	string
129
	 */
130
	protected function _list_columns($table = '')
131
	{
132
		return 'SELECT '.$this->escape_identifiers('COLUMN_NAME').' FROM '.$this->escape_identifiers('_USER_COLUMNS')
133
			.' WHERE '.$this->escape_identifiers('TABLE_NAME').' = '.$this->escape($table);
134
	}
135
 
136
	// --------------------------------------------------------------------
137
 
138
	/**
139
	 * Field data query
140
	 *
141
	 * Generates a platform-specific query so that the column data can be retrieved
142
	 *
143
	 * @param	string	$table
144
	 * @return	string
145
	 */
146
	protected function _field_data($table)
147
	{
148
		return 'SELECT * FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' LIMIT 1';
149
	}
150
 
151
	// --------------------------------------------------------------------
152
 
153
	/**
154
	 * Update statement
155
	 *
156
	 * Generates a platform-specific update string from the supplied data
157
	 *
158
	 * @param	string	$table
159
	 * @param	array	$values
160
	 * @return	string
161
	 */
162
	protected function _update($table, $values)
163
	{
164
		$this->qb_limit = FALSE;
165
		$this->qb_orderby = array();
166
		return parent::_update($table, $values);
167
	}
168
 
169
	// --------------------------------------------------------------------
170
 
171
	/**
172
	 * Delete statement
173
	 *
174
	 * Generates a platform-specific delete string from the supplied data
175
	 *
176
	 * @param	string	$table
177
	 * @return	string
178
	 */
179
	protected function _delete($table)
180
	{
181
		$this->qb_limit = FALSE;
182
		return parent::_delete($table);
183
	}
184
 
185
	// --------------------------------------------------------------------
186
 
187
	/**
188
	 * LIMIT
189
	 *
190
	 * Generates a platform-specific LIMIT clause
191
	 *
192
	 * @param	string	$sql	SQL Query
193
	 * @return	string
194
	 */
195
	protected function _limit($sql)
196
	{
197
		return $sql.' LIMIT '.$this->qb_limit.($this->qb_offset ? ' OFFSET '.$this->qb_offset : '');
198
	}
199
 
200
}