1 | <?php |
||
18 | class QueryFactory |
||
19 | { |
||
20 | const COMMON = 'common'; |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | * What database are we building for? |
||
25 | * |
||
26 | * @param string |
||
27 | * |
||
28 | */ |
||
29 | protected $db; |
||
30 | |||
31 | /** |
||
32 | * |
||
33 | * Build "common" query objects regardless of database type? |
||
34 | * |
||
35 | * @param bool |
||
36 | * |
||
37 | */ |
||
38 | protected $common = false; |
||
39 | |||
40 | /** |
||
41 | * |
||
42 | * A map of `table.col` names to last-insert-id names. |
||
43 | * |
||
44 | * @var array |
||
45 | * |
||
46 | */ |
||
47 | protected $last_insert_id_names = array(); |
||
48 | |||
49 | /** |
||
50 | * |
||
51 | * A Quoter for identifiers. |
||
52 | * |
||
53 | * @param QuoterInterface |
||
54 | * |
||
55 | */ |
||
56 | protected $quoter; |
||
57 | |||
58 | /** |
||
59 | * |
||
60 | * A count of Query instances, used for determining $seq_bind_prefix. |
||
61 | * |
||
62 | * @var int |
||
63 | * |
||
64 | */ |
||
65 | protected $instance_count = 0; |
||
66 | |||
67 | /** |
||
68 | * |
||
69 | * Constructor. |
||
70 | * |
||
71 | * @param string $db The database type. |
||
72 | * |
||
73 | * @param string $common Pass the constant self::COMMON to force common |
||
74 | * query objects instead of db-specific ones. |
||
75 | * |
||
76 | */ |
||
77 | 408 | public function __construct($db, $common = null) |
|
82 | |||
83 | /** |
||
84 | * |
||
85 | * Sets the last-insert-id names to be used for Insert queries.. |
||
86 | * |
||
87 | * @param array $last_insert_id_names A map of `table.col` names to |
||
88 | * last-insert-id names. |
||
89 | * |
||
90 | * @return null |
||
91 | * |
||
92 | */ |
||
93 | 67 | public function setLastInsertIdNames(array $last_insert_id_names) |
|
97 | |||
98 | /** |
||
99 | * |
||
100 | * Returns a new SELECT object. |
||
101 | * |
||
102 | * @return Common\SelectInterface |
||
103 | * |
||
104 | */ |
||
105 | 265 | public function newSelect() |
|
109 | |||
110 | /** |
||
111 | * |
||
112 | * Returns a new INSERT object. |
||
113 | * |
||
114 | * @return Common\InsertInterface |
||
115 | * |
||
116 | */ |
||
117 | 77 | public function newInsert() |
|
123 | |||
124 | /** |
||
125 | * |
||
126 | * Returns a new UPDATE object. |
||
127 | * |
||
128 | * @return Common\UpdateInterface |
||
129 | * |
||
130 | */ |
||
131 | 38 | public function newUpdate() |
|
135 | |||
136 | /** |
||
137 | * |
||
138 | * Returns a new DELETE object. |
||
139 | * |
||
140 | * @return Common\DeleteInterface |
||
141 | * |
||
142 | */ |
||
143 | 28 | public function newDelete() |
|
147 | |||
148 | /** |
||
149 | * |
||
150 | * Returns a new query object. |
||
151 | * |
||
152 | * @param string $query The query object type. |
||
153 | * |
||
154 | * @return AbstractQuery |
||
155 | * |
||
156 | */ |
||
157 | 408 | protected function newInstance($query) |
|
175 | |||
176 | 408 | protected function newBuilder($query) |
|
184 | |||
185 | /** |
||
186 | * |
||
187 | * Returns the Quoter object for queries; creates one if needed. |
||
188 | * |
||
189 | * @return Quoter |
||
190 | * |
||
191 | */ |
||
192 | 408 | protected function getQuoter() |
|
199 | |||
200 | 408 | protected function newQuoter() |
|
208 | /** |
||
209 | * |
||
210 | * Returns a new sequential-placeholder prefix for a query object. |
||
211 | * |
||
212 | * We need these to deconflict between bound values in subselect queries. |
||
213 | * |
||
214 | * @return string |
||
215 | * |
||
216 | */ |
||
217 | 408 | protected function newSeqBindPrefix() |
|
227 | } |
||
228 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.