# e2pdf/1.02.02/classes/helper/e2pdf-db.php

E2Pdf – Export Pdf Tool for WordPress, version 1.02.02. 70 lines.

- Page: https://pluginprobe.com/plugins/e2pdf/1.02.02/code/classes/helper/e2pdf-db.php
- Raw: https://pluginprobe.com/plugins/e2pdf/1.02.02/raw/classes/helper/e2pdf-db.php
- Modified: 2018-12-07T12:07:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/e2pdf/1.02.02/code/classes/helper/e2pdf-db.php#L10-L20`.

```php
<?php

/**
 * E2pdf Get Helper
 * 
 * @copyright  Copyright 2017 https://e2pdf.com
 * @license    GPL v2
 * @version    1
 * @link       https://e2pdf.com
 * @since      0.00.01
 */
if (!defined('ABSPATH')) {
    die('Access denied.');
}

class Helper_E2pdf_Db {

    /**
     * Prepare WHERE for sql requests
     * 
     * @param string $condition - Array of conditions
     * 
     * @return array - Filtered WHERE request
     */
    public function prepare_where($condition = array()) {

        $sql = array();
        $filter = array();

        $sql[] = " WHERE '1' = '1'";
        if (!empty($condition)) {
            foreach ($condition as $key => $value) {
                if (is_array($value['value'])) {
                    foreach ($value['value'] as $sub_value) {
                        $sql[] = " `{$key}` {$value['condition']} '{$value['type']}'";
                        $filter[] = $sub_value;
                    }
                } else {
                    $sql[] = " `{$key}` {$value['condition']} '{$value['type']}'";
                    $filter[] = $value['value'];
                }
            }
        }

        $where = array(
            'sql' => implode(' AND', $sql),
            'filter' => $filter
        );


        return $where;
    }

    /**
     * Prepare ORDER_BY for sql requests
     * 
     * @param string $condition - Array of conditions
     * 
     * @return array - Filtered ORDER_BY request
     */
    public function prepare_orderby($condition = array()) {
        $orderby = '';
        if (isset($condition['orderby']) && isset($condition['order'])) {
            $orderby .= " ORDER BY {$condition['orderby']} {$condition['order']}";
        }
        return $orderby;
    }

}

```
