|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package Redcore |
|
4
|
|
|
* @subpackage Database |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) 2008 - 2020 redWEB.dk. All rights reserved. |
|
7
|
|
|
* @license GNU General Public License version 2 or later, see LICENSE. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
defined('JPATH_REDCORE') or die; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* MySQL database driver supporting PDO based connections |
|
14
|
|
|
* |
|
15
|
|
|
* @package Redcore |
|
16
|
|
|
* @subpackage Database |
|
17
|
|
|
* @since __DEPLOY_VERSION__ |
|
18
|
|
|
*/ |
|
19
|
|
|
class RDatabaseDriverPdomysql extends JDatabaseDriverPdomysql |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* We can choose not to translate query with this variable |
|
23
|
|
|
* |
|
24
|
|
|
* @var boolean |
|
25
|
|
|
*/ |
|
26
|
|
|
public $translate = false; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* This function replaces a string identifier <var>$prefix</var> with the string held is the |
|
30
|
|
|
* <var>tablePrefix</var> class variable. |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $sql The SQL statement to prepare. |
|
33
|
|
|
* @param string $prefix The common table prefix. |
|
34
|
|
|
* @param bool $insideQuotes Replace prefix inside quotes too |
|
35
|
|
|
* |
|
36
|
|
|
* @return string The processed SQL statement. |
|
37
|
|
|
* |
|
38
|
|
|
* @since 11.1 |
|
39
|
|
|
*/ |
|
40
|
|
|
public function replacePrefix($sql, $prefix = '#__', $insideQuotes = false) |
|
41
|
|
|
{ |
|
42
|
|
|
// Basic check for translations |
|
43
|
|
|
if ($this->translate) |
|
44
|
|
|
{ |
|
45
|
|
|
if ($parsedSql = RDatabaseSqlparserSqltranslation::buildTranslationQuery($sql, $prefix)) |
|
46
|
|
|
{ |
|
47
|
|
|
return RHelperDatabase::replacePrefix($parsedSql, $this->tablePrefix, $prefix, $insideQuotes); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return RHelperDatabase::replacePrefix($sql, $this->tablePrefix, $prefix, $insideQuotes); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Execute the SQL statement. |
|
56
|
|
|
* |
|
57
|
|
|
* @param boolean $replacePrefixQuotes Replace the prefixes inside the quotes too |
|
58
|
|
|
* |
|
59
|
|
|
* @return mixed A database cursor resource on success, boolean false on failure. |
|
60
|
|
|
* |
|
61
|
|
|
* @since 12.1 |
|
62
|
|
|
* @throws RuntimeException |
|
63
|
|
|
*/ |
|
64
|
|
|
public function execute($replacePrefixQuotes = false) |
|
65
|
|
|
{ |
|
66
|
|
|
if ($replacePrefixQuotes) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->sql = $this->replacePrefix((string) $this->sql, '#__', $replacePrefixQuotes); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return parent::execute(); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|