|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2023 |
|
6
|
|
|
* @package Base |
|
7
|
|
|
* @subpackage Common |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Base\Criteria\Expression\Sort; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* PostgreSQL implementation for sorting entries |
|
16
|
|
|
* |
|
17
|
|
|
* @package Base |
|
18
|
|
|
* @subpackage Common |
|
19
|
|
|
*/ |
|
20
|
|
|
class PgSQL extends SQL |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Escapes the value so it can be inserted into a SQL statement |
|
24
|
|
|
* |
|
25
|
|
|
* @param string $operator Operator used for the expression |
|
26
|
|
|
* @param string $type Type constant |
|
27
|
|
|
* @param mixed $value Value that the variable or column should be compared to |
|
28
|
|
|
* @return double|string|integer Escaped value |
|
29
|
|
|
*/ |
|
30
|
|
|
protected function escape( string $operator, string $type, $value ) |
|
31
|
|
|
{ |
|
32
|
|
|
$value = $this->translateValue( $this->getName(), $value, $type ); |
|
33
|
|
|
|
|
34
|
|
|
switch( $type ) |
|
35
|
|
|
{ |
|
36
|
|
|
case \Aimeos\Base\DB\Statement\Base::PARAM_NULL: |
|
37
|
|
|
$value = 'null'; break; |
|
38
|
|
|
case \Aimeos\Base\DB\Statement\Base::PARAM_BOOL: |
|
39
|
|
|
$value = ( $value ? "'t'" : "'f'" ); break; |
|
40
|
|
|
case \Aimeos\Base\DB\Statement\Base::PARAM_INT: |
|
41
|
|
|
$value = (int) $value; break; |
|
42
|
|
|
case \Aimeos\Base\DB\Statement\Base::PARAM_FLOAT: |
|
43
|
|
|
$value = (double) $value; break; |
|
44
|
|
|
case \Aimeos\Base\DB\Statement\Base::PARAM_STR: |
|
45
|
|
|
if( $operator === '~=' ) { |
|
46
|
|
|
$value = '\'%' . str_replace( ['#', '%', '_', '['], ['##', '#%', '#_', '#['], $this->getConnection()->escape( (string) $value ) ) . '%\''; break; |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
if( $operator === '=~' ) { |
|
49
|
|
|
$value = '\'' . str_replace( ['#', '%', '_', '['], ['##', '#%', '#_', '#['], $this->getConnection()->escape( (string) $value ) ) . '%\''; break; |
|
50
|
|
|
} |
|
51
|
|
|
// all other operators: escape in default case |
|
52
|
|
|
default: |
|
53
|
|
|
$value = '\'' . $this->getConnection()->escape( (string) $value ) . '\''; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return $value; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.