1 | <?php |
||
7 | class SubQuery |
||
8 | { |
||
9 | /** |
||
10 | * @const ERR_QUERY_NOT_OBJECT_OR_STRING Exception code if the query is |
||
11 | * not an object or a string. |
||
12 | */ |
||
13 | const ERR_QUERY_NOT_OBJECT_OR_STRING = 2513001; |
||
14 | |||
15 | /** |
||
16 | * @const ERR_QUERY_OBJECT_BAD_INSTANCE Exception code in the case of |
||
17 | * the query is an object but with not the expected class. |
||
18 | */ |
||
19 | const ERR_QUERY_OBJECT_BAD_INSTANCE = 2513002; |
||
20 | |||
21 | /** |
||
22 | * @var string $query The sub-query |
||
23 | */ |
||
24 | protected $query = ''; |
||
25 | |||
26 | /** |
||
27 | * @var string $shortcut The shortcut to use into the request |
||
28 | */ |
||
29 | protected $shortcut = ''; |
||
30 | |||
31 | /** |
||
32 | * Define the shortcut and the sql query. |
||
33 | * If the sub-query is an object, call method to obtain the string query |
||
34 | * |
||
35 | * @param string $shortcut The shortcut to use into the request |
||
36 | * @param string|\BfwSql\Queries\AbstractQuery $query The sub-query |
||
37 | */ |
||
38 | public function __construct(string $shortcut, $query) |
||
43 | |||
44 | /** |
||
45 | * Getter accessor to property query |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | public function getQuery(): string |
||
53 | |||
54 | /** |
||
55 | * Getter accessor to property shortcut |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getShortcut(): string |
||
63 | |||
64 | /** |
||
65 | * Obtain the sql request (string type) from the arguments |
||
66 | * If it's already a string, just return the string. |
||
67 | * Else, if it's an AbstractQuery, use the method assemble() to obtain |
||
68 | * the string sql request. |
||
69 | * |
||
70 | * @param string|\BfwSql\Queries\AbstractQuery $query The sub-query |
||
71 | * |
||
72 | * @return string |
||
73 | * |
||
74 | * @throws \Exception If the sub-query has not the correct type or if it's |
||
75 | * not the correct class instance. |
||
76 | */ |
||
77 | protected function obtainAssembledQuery($query): string |
||
100 | |||
101 | /** |
||
102 | * Generate the sql query to use for to this sub-query |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function generate(): string |
||
110 | } |
||
111 |