1 | <?php |
||
17 | class DBQuery { |
||
18 | |||
19 | /* Service variables */ |
||
20 | |||
21 | /** |
||
22 | * Type of the SQL query. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $type = DBQueryType::SELECT; |
||
27 | |||
28 | /** |
||
29 | * SQL conditions list. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | public $conditions = []; |
||
34 | |||
35 | /** |
||
36 | * SQL fields list for INSERT/UPDATE queries. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | public $fields = []; |
||
41 | |||
42 | /** |
||
43 | * SQL order list. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | public $order = null; |
||
48 | |||
49 | /** |
||
50 | * SQL limit value (may be pair array or integer value). |
||
51 | * |
||
52 | * @var mixed |
||
53 | */ |
||
54 | public $limit = null; |
||
55 | |||
56 | /** |
||
57 | * Creates new DBQuery object with SQL type initialized. |
||
58 | * |
||
59 | * @param string $type SQL query type. |
||
60 | */ |
||
61 | public function __construct($type = DBQueryType::SELECT) { |
||
64 | |||
65 | /** |
||
66 | * Sets SQL query type with additional query type validation. |
||
67 | * |
||
68 | * @param string $type SQL query type. |
||
69 | * @throws DBCoreException If invalid query type provided. |
||
70 | */ |
||
71 | public function setType($type = DBQueryType::SELECT) { |
||
78 | |||
79 | /** |
||
80 | * Returns SQL query type. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getType() { |
||
87 | |||
88 | /** |
||
89 | * Detects type of the SQL query. |
||
90 | * |
||
91 | * @return string Type of the SQL query. |
||
92 | * @throws DBCoreException If SQL query is invalid. |
||
93 | */ |
||
94 | protected function detectType() { |
||
97 | |||
98 | /** |
||
99 | * Detects if DB query is selector query. |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | public function isSelector() { |
||
106 | |||
107 | /** |
||
108 | * Detects if DB query is modifier query. |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function isModifier() { |
||
115 | |||
116 | /** |
||
117 | * Outputs DB query debug information to the stream. |
||
118 | * |
||
119 | * @param string $query SQL query. |
||
120 | * @param string $types SQL types string. |
||
121 | * @param array $params List of SQL query parameters. |
||
122 | */ |
||
123 | public static function showQueryDebugInfo($query = "", $types = "", array $params = []) { |
||
155 | |||
156 | } |
||
157 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: