PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.01.01
E2Pdf – Export Pdf Tool for WordPress v1.01.01
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
e2pdf / classes / helper / e2pdf-db.php

e2pdf-db.php in E2Pdf – Export Pdf Tool for WordPress 1.01.01, at classes/helper/e2pdf-db.php

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Get Helper
5 *
6 * @copyright Copyright 2017 https://e2pdf.com
7 * @license GPL v2
8 * @version 1
9 * @link https://e2pdf.com
10 * @since 0.00.01
11 */
12 if (!defined('ABSPATH')) {
13 die('Access denied.');
14 }
15
16 class Helper_E2pdf_Db {
17
18 /**
19 * Prepare WHERE for sql requests
20 *
21 * @param string $condition - Array of conditions
22 *
23 * @return array - Filtered WHERE request
24 */
25 public function prepare_where($condition = array()) {
26
27 $sql = array();
28 $filter = array();
29
30 $sql[] = " WHERE '1' = '1'";
31 if (!empty($condition)) {
32 foreach ($condition as $key => $value) {
33 if (is_array($value['value'])) {
34 foreach ($value['value'] as $sub_value) {
35 $sql[] = " `{$key}` {$value['condition']} '{$value['type']}'";
36 $filter[] = $sub_value;
37 }
38 } else {
39 $sql[] = " `{$key}` {$value['condition']} '{$value['type']}'";
40 $filter[] = $value['value'];
41 }
42 }
43 }
44
45 $where = array(
46 'sql' => implode(' AND', $sql),
47 'filter' => $filter
48 );
49
50
51 return $where;
52 }
53
54 /**
55 * Prepare ORDER_BY for sql requests
56 *
57 * @param string $condition - Array of conditions
58 *
59 * @return array - Filtered ORDER_BY request
60 */
61 public function prepare_orderby($condition = array()) {
62 $orderby = '';
63 if (isset($condition['orderby']) && isset($condition['order'])) {
64 $orderby .= " ORDER BY {$condition['orderby']} {$condition['order']}";
65 }
66 return $orderby;
67 }
68
69 }
70