Advertisement
Guest User

Untitled

a guest
May 11th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.8.9
  8. * @ Author : DeZender
  9. * @ Release on : 10.05.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class SearchBase
  15. {
  16. protected $tbl;
  17. protected $joins;
  18. protected $pageSize;
  19. protected $page;
  20. protected $flds;
  21. protected $error;
  22. protected $order;
  23. protected $groupby;
  24. protected $results_found;
  25. protected $calculateRecords;
  26. protected $limitRecords;
  27. protected $conditions;
  28. protected $havings;
  29. protected $bindValues;
  30. protected $skipRecordCount = 0;
  31. protected $fetchRecordCount = 0;
  32.  
  33. public function __construct($tbl, $alias = '')
  34. {
  35. $this->flds = [];
  36. $this->joins = [];
  37. $this->pageSize = 2000;
  38. $this->order = [];
  39. $this->error = '';
  40. $this->page = 1;
  41. $this->groupby = [];
  42. $this->tbl = $tbl;
  43.  
  44. if (strpos($this->tbl, '`') === false) {
  45. $this->tbl = '`' . $tbl . '`';
  46. }
  47.  
  48. $this->calculateRecords = true;
  49. $this->limitRecords = true;
  50. $this->conditions = [];
  51. $this->havings = [];
  52.  
  53. if ($alias != '') {
  54. $this->tbl .= ' ' . $alias;
  55. }
  56.  
  57. $this->bindValues = [];
  58. }
  59.  
  60. public function doNotCalculateRecords()
  61. {
  62. $this->calculateRecords = false;
  63. }
  64.  
  65. public function doNotLimitRecords()
  66. {
  67. $this->limitRecords = false;
  68. }
  69.  
  70. public function addFld($fld)
  71. {
  72. if (is_array($fld)) {
  73. $this->addMultipleFields($fld);
  74. return NULL;
  75. }
  76.  
  77. if (!in_array($fld, $this->flds)) {
  78. $this->flds[] = $fld;
  79. }
  80. }
  81.  
  82. public function addMultipleFields($arr)
  83. {
  84. foreach ($arr as $val) {
  85. $this->addFld($val);
  86. }
  87. }
  88.  
  89. public function joinTable($tbl, $join_type, $on, $alias = '')
  90. {
  91. $arr = ['tbl' => $tbl, 'join_type' => $join_type, 'on' => $on, 'alias' => $alias];
  92.  
  93. if (!in_array($arr, $this->joins)) {
  94. $this->joins[] = $arr;
  95. }
  96. }
  97.  
  98. public function addDirectCondition($cndString, $glue = 'AND')
  99. {
  100. $cnd = new SearchCondition('', '', '');
  101. $cnd->setDirectString($cndString);
  102. $this->conditions[] = ['condition' => $cnd, 'glue' => $glue];
  103. return $cnd;
  104. }
  105.  
  106. public function addCondition($fld, $operator, $val, $glue = 'AND', $execute_mysql_functions = false)
  107. {
  108. $cnd = new SearchCondition($fld, $operator, $val, $execute_mysql_functions);
  109. $this->conditions[] = ['condition' => $cnd, 'glue' => $glue];
  110. return $cnd;
  111. }
  112.  
  113. public function addHaving($fld, $operator, $val, $glue = 'AND', $execute_mysql_functions = false)
  114. {
  115. $cnd = new SearchCondition($fld, $operator, $val, $execute_mysql_functions);
  116. $this->havings[] = ['condition' => $cnd, 'glue' => $glue];
  117. return $cnd;
  118. }
  119.  
  120. public function setPageSize($pageSize)
  121. {
  122. $pageSize = FatUtility::convertToType($pageSize, FatUtility::VAR_INT);
  123.  
  124. if ($pageSize <= 0) {
  125. trigger_error('Invalid Value of page size', 256);
  126. exit();
  127. }
  128.  
  129. $this->pageSize = $pageSize;
  130. }
  131.  
  132. public function setPageNumber($page)
  133. {
  134. $page = FatUtility::convertToType($page, FatUtility::VAR_INT);
  135.  
  136. if ($page <= 0) {
  137. trigger_error('Invalid Value of page number', 256);
  138. exit();
  139. }
  140.  
  141. $this->page = $page;
  142. }
  143.  
  144. public function setSkipRecordCount($n)
  145. {
  146. $n = FatUtility::convertToType($n, FatUtility::VAR_INT);
  147.  
  148. if ($n < 0) {
  149. trigger_error('Invalid Value of records to skip', 256);
  150. exit();
  151. }
  152.  
  153. $this->skipRecordCount = $n;
  154. }
  155.  
  156. public function setFetchRecordCount($n)
  157. {
  158. $n = FatUtility::convertToType($n, FatUtility::VAR_INT);
  159.  
  160. if ($n <= 0) {
  161. trigger_error('Invalid Value of records to fetch', 256);
  162. exit();
  163. }
  164.  
  165. $this->fetchRecordCount = $n;
  166. }
  167.  
  168. protected function getJoinsString()
  169. {
  170. $str = '';
  171.  
  172. foreach ($this->joins as $arr) {
  173. $str .= ' ' . "\n" . $arr['join_type'] . ' ';
  174. if ((strpos(strtolower($arr['tbl']), 'select ') !== false) && (50 < strlen($arr['tbl']))) {
  175. $str .= $arr['tbl'];
  176. }
  177. else {
  178. $str .= '`' . $arr['tbl'] . '`';
  179. }
  180.  
  181. $str .= ' ';
  182.  
  183. if ($arr['alias'] != '') {
  184. $str .= ' AS ' . $arr['alias'] . ' ';
  185. }
  186.  
  187. if ($arr['on'] != '') {
  188. $str .= ' ' . "\n" . ' ON ' . $arr['on'] . ' ';
  189. }
  190. }
  191.  
  192. return $str;
  193. }
  194.  
  195. public function addGroupBy($fld)
  196. {
  197. $fld = trim($fld);
  198. if (($fld != '') && !in_array($fld, $this->groupby)) {
  199. $this->groupby[] = $fld;
  200. }
  201. }
  202.  
  203. public function removGroupBy($fld)
  204. {
  205. $fld = trim($fld);
  206. ...........................................................
  207. ..............................
  208. ...........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement