1 | <?php |
||
3 | class DbSqlAware { |
||
4 | /** |
||
5 | * @var db_mysql $db |
||
6 | */ |
||
7 | protected $db; |
||
8 | |||
9 | /** |
||
10 | * DbSqlAware constructor. |
||
11 | * |
||
12 | * @param db_mysql|null $db |
||
13 | */ |
||
14 | 2 | public function __construct($db = null) { |
|
17 | |||
18 | /** |
||
19 | * @param db_mysql|null $db |
||
20 | * |
||
21 | * @return static |
||
22 | */ |
||
23 | 2 | public static function build($db = null) { |
|
26 | |||
27 | /** |
||
28 | * @return db_mysql|null |
||
29 | */ |
||
30 | public function getDb() { |
||
31 | return $this->db; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param db_mysql|null $db |
||
36 | */ |
||
37 | public function setDb($db) { |
||
38 | $this->db = $db; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Just escapes string used DB string escape method - or a drop-in replacement addslashes() if not DB specified |
||
43 | * |
||
44 | * @param string $string |
||
45 | * |
||
46 | * @return mixed|string |
||
47 | */ |
||
48 | 1 | protected function escapeString($string) { |
|
54 | |||
55 | /** |
||
56 | * Quotes string by ref as DDL ID (i.e. field or table name) - except '*' which not quoted |
||
57 | * |
||
58 | * @param string &$string |
||
59 | */ |
||
60 | 7 | protected function quoteFieldSimpleByRef(&$string) { |
|
66 | |||
67 | /** |
||
68 | * Escapes field - include fully qualified field like table.field, table.* and mask '*' |
||
69 | * |
||
70 | * @param string $string |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | 5 | protected function quoteField($string) { |
|
84 | |||
85 | /** |
||
86 | * Making and alias from fully qualified field name prepending with function name |
||
87 | * |
||
88 | * @param string $functionName |
||
89 | * @param string $field |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 4 | protected function aliasFromField($functionName, $field) { |
|
111 | |||
112 | } |
||
113 |