| @@ -1,16 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm\Core\Database; |
| 4 | 4 | |
| 5 | -final class Helper { | |
| 5 | +final class Helper | |
| 6 | +{ | |
| 6 | 7 | // public static function getTableName($className) |
| 7 | 8 | // { |
| 8 | - // $className = str_replace('\\', '', $className); | |
| 9 | - // $className = str_replace('Model', '', $className); | |
| 10 | - // return strtolower($className); | |
| 9 | + // $className = str_replace('\\', '', $className); | |
| 10 | + // $className = str_replace('Model', '', $className); | |
| 11 | + // return strtolower($className); | |
| 11 | 12 | // } |
| 12 | - public function arrValueModifyByLogic($operator, $value) { | |
| 13 | + public function arrValueModifyByLogic($operator, $value) | |
| 14 | + { | |
| 13 | 15 | $oprators = [ |
| 14 | 16 | 'equal' => '["' . implode('","', $value) . '"]', |
| 15 | 17 | 'not_equal' => '["' . implode('","', $value) . '"]', |
| 16 | 18 | 'start_with' => '["' . implode('","', $value) . '"%', |
| @@ -29,9 +31,10 @@ | ||
| 29 | 31 | |
| 30 | 32 | return $value; |
| 31 | 33 | } |
| 32 | 34 | |
| 33 | - public function dateQueryList() { | |
| 35 | + public function dateQueryList() | |
| 36 | + { | |
| 34 | 37 | return [ |
| 35 | 38 | 'today' => 'Y-m-d_+0 days_=', |
| 36 | 39 | 'till_today' => 'Y-m-d_+0 days_<=', |
| 37 | 40 | 'tomorrow' => 'Y-m-d_+1 days_=', |
| @@ -59,9 +62,10 @@ | ||
| 59 | 62 | 'last_year' => 'Y_-1 year_=', |
| 60 | 63 | ]; |
| 61 | 64 | } |
| 62 | 65 | |
| 63 | - public function strValueModifyByLogic($operator, $value) { | |
| 66 | + public function strValueModifyByLogic($operator, $value) | |
| 67 | + { | |
| 64 | 68 | $timeInterval = $this->dateQueryList(); |
| 65 | 69 | |
| 66 | 70 | if (isset($timeInterval[$operator])) { |
| 67 | 71 | $data = explode('_', $timeInterval[$operator]); |
| @@ -95,9 +99,10 @@ | ||
| 95 | 99 | |
| 96 | 100 | return $value; |
| 97 | 101 | } |
| 98 | 102 | |
| 99 | - public function convertToSqlOperator($operator) { | |
| 103 | + public function convertToSqlOperator($operator) | |
| 104 | + { | |
| 100 | 105 | $timeInterval = $this->dateQueryList(); |
| 101 | 106 | |
| 102 | 107 | if (isset($timeInterval[$operator])) { |
| 103 | 108 | $data = explode('_', $timeInterval[$operator]); |
| @@ -127,9 +132,10 @@ | ||
| 127 | 132 | |
| 128 | 133 | return $operator; |
| 129 | 134 | } |
| 130 | 135 | |
| 131 | - public function fieldQueryByDate($fld, $operator, $value, $logic) { | |
| 136 | + public function fieldQueryByDate($fld, $operator, $value, $logic) | |
| 137 | + { | |
| 132 | 138 | $currentYear = date('Y'); |
| 133 | 139 | |
| 134 | 140 | $sql = ''; |
| 135 | 141 | |