Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.0.8.9
- * @ Author : DeZender
- * @ Release on : 10.05.2019
- * @ Official site : http://DeZender.Net
- *
- */
- class SearchBase
- {
- protected $tbl;
- protected $joins;
- protected $pageSize;
- protected $page;
- protected $flds;
- protected $error;
- protected $order;
- protected $groupby;
- protected $results_found;
- protected $calculateRecords;
- protected $limitRecords;
- protected $conditions;
- protected $havings;
- protected $bindValues;
- protected $skipRecordCount = 0;
- protected $fetchRecordCount = 0;
- public function __construct($tbl, $alias = '')
- {
- $this->flds = [];
- $this->joins = [];
- $this->pageSize = 2000;
- $this->order = [];
- $this->error = '';
- $this->page = 1;
- $this->groupby = [];
- $this->tbl = $tbl;
- if (strpos($this->tbl, '`') === false) {
- $this->tbl = '`' . $tbl . '`';
- }
- $this->calculateRecords = true;
- $this->limitRecords = true;
- $this->conditions = [];
- $this->havings = [];
- if ($alias != '') {
- $this->tbl .= ' ' . $alias;
- }
- $this->bindValues = [];
- }
- public function doNotCalculateRecords()
- {
- $this->calculateRecords = false;
- }
- public function doNotLimitRecords()
- {
- $this->limitRecords = false;
- }
- public function addFld($fld)
- {
- if (is_array($fld)) {
- $this->addMultipleFields($fld);
- return NULL;
- }
- if (!in_array($fld, $this->flds)) {
- $this->flds[] = $fld;
- }
- }
- public function addMultipleFields($arr)
- {
- foreach ($arr as $val) {
- $this->addFld($val);
- }
- }
- public function joinTable($tbl, $join_type, $on, $alias = '')
- {
- $arr = ['tbl' => $tbl, 'join_type' => $join_type, 'on' => $on, 'alias' => $alias];
- if (!in_array($arr, $this->joins)) {
- $this->joins[] = $arr;
- }
- }
- public function addDirectCondition($cndString, $glue = 'AND')
- {
- $cnd = new SearchCondition('', '', '');
- $cnd->setDirectString($cndString);
- $this->conditions[] = ['condition' => $cnd, 'glue' => $glue];
- return $cnd;
- }
- public function addCondition($fld, $operator, $val, $glue = 'AND', $execute_mysql_functions = false)
- {
- $cnd = new SearchCondition($fld, $operator, $val, $execute_mysql_functions);
- $this->conditions[] = ['condition' => $cnd, 'glue' => $glue];
- return $cnd;
- }
- public function addHaving($fld, $operator, $val, $glue = 'AND', $execute_mysql_functions = false)
- {
- $cnd = new SearchCondition($fld, $operator, $val, $execute_mysql_functions);
- $this->havings[] = ['condition' => $cnd, 'glue' => $glue];
- return $cnd;
- }
- public function setPageSize($pageSize)
- {
- $pageSize = FatUtility::convertToType($pageSize, FatUtility::VAR_INT);
- if ($pageSize <= 0) {
- trigger_error('Invalid Value of page size', 256);
- exit();
- }
- $this->pageSize = $pageSize;
- }
- public function setPageNumber($page)
- {
- $page = FatUtility::convertToType($page, FatUtility::VAR_INT);
- if ($page <= 0) {
- trigger_error('Invalid Value of page number', 256);
- exit();
- }
- $this->page = $page;
- }
- public function setSkipRecordCount($n)
- {
- $n = FatUtility::convertToType($n, FatUtility::VAR_INT);
- if ($n < 0) {
- trigger_error('Invalid Value of records to skip', 256);
- exit();
- }
- $this->skipRecordCount = $n;
- }
- public function setFetchRecordCount($n)
- {
- $n = FatUtility::convertToType($n, FatUtility::VAR_INT);
- if ($n <= 0) {
- trigger_error('Invalid Value of records to fetch', 256);
- exit();
- }
- $this->fetchRecordCount = $n;
- }
- protected function getJoinsString()
- {
- $str = '';
- foreach ($this->joins as $arr) {
- $str .= ' ' . "\n" . $arr['join_type'] . ' ';
- if ((strpos(strtolower($arr['tbl']), 'select ') !== false) && (50 < strlen($arr['tbl']))) {
- $str .= $arr['tbl'];
- }
- else {
- $str .= '`' . $arr['tbl'] . '`';
- }
- $str .= ' ';
- if ($arr['alias'] != '') {
- $str .= ' AS ' . $arr['alias'] . ' ';
- }
- if ($arr['on'] != '') {
- $str .= ' ' . "\n" . ' ON ' . $arr['on'] . ' ';
- }
- }
- return $str;
- }
- public function addGroupBy($fld)
- {
- $fld = trim($fld);
- if (($fld != '') && !in_array($fld, $this->groupby)) {
- $this->groupby[] = $fld;
- }
- }
- public function removGroupBy($fld)
- {
- $fld = trim($fld);
- ...........................................................
- ..............................
- ...........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement