PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.1.4
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.1.4
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Helpers / global / query.php

query.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.1.4, at back/Helpers/global/query.php

66 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function acym_getTables()
4 {
5 static $tables = null;
6 if (empty($tables)) {
7 $tables = acym_loadResultArray('SHOW TABLES');
8 }
9
10 return $tables;
11 }
12
13 function acym_getColumns(string $table, bool $acyTable = true, bool $addPrefix = true)
14 {
15 if ($addPrefix) {
16 $prefix = $acyTable ? '#__acym_' : '#__';
17 $table = $prefix.$table;
18 }
19
20 static $columns = [];
21 if (empty($columns[$table])) {
22 $columns[$table] = acym_loadResultArray('SHOW COLUMNS FROM '.acym_secureDBColumn($table));
23 }
24
25 return $columns[$table];
26 }
27
28 function acym_secureDBColumn($fieldName)
29 {
30 if (!is_string($fieldName) || preg_match('|[^a-z0-9#_.-]|i', $fieldName) !== 0) {
31 die('field, table or database "'.acym_escape($fieldName).'" not secured');
32 }
33
34 return $fieldName;
35 }
36
37 function acym_getDatabases()
38 {
39 try {
40 $allDatabases = acym_loadResultArray('SHOW DATABASES');
41 } catch (Exception $exception) {
42 $allDatabases = [];
43 $allDatabases[] = acym_loadResult('SELECT DATABASE();');
44 }
45
46 $databases = [];
47 foreach ($allDatabases as $database) {
48 $databases[$database] = $database;
49 }
50
51 return $databases;
52 }
53
54 function acym_addLimit(string &$query, int $limit = 1, ?int $offset = null)
55 {
56 if (strpos($query, 'LIMIT ') !== false) {
57 return;
58 }
59
60 $query .= ' LIMIT ';
61 if (!empty($offset)) {
62 $query .= intval($offset).',';
63 }
64 $query .= intval($limit);
65 }
66