Revize cd67c936
Přidáno uživatelem Ondřej Anděl před téměř 4 roky(ů)
application/model/DB.php | ||
---|---|---|
118 | 118 |
return $this->stmt->fetchAll(); |
119 | 119 |
} |
120 | 120 |
|
121 |
|
|
122 |
|
|
123 |
function update(){ |
|
124 |
$query = "SELECT id FROM dd_lemma |
|
125 |
WHERE lemma = :lemma;"; |
|
126 |
$this->stmt = $this->pdo->prepare($query); |
|
127 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
128 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
129 |
} |
|
130 |
$this->stmt->execute(); |
|
131 |
$lemma = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
132 |
|
|
133 |
$query = "SELECT id FROM dd_tag |
|
134 |
WHERE tag = :tag;"; |
|
135 |
$this->stmt = $this->pdo->prepare($query); |
|
136 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
137 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
138 |
} |
|
139 |
$this->stmt->execute(); |
|
140 |
$tag = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
141 |
|
|
142 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
143 |
if($lemma == null){ |
|
144 |
$query = "SELECT MAX(id) FROM dd_lemma;"; |
|
145 |
$this->stmt = $this->pdo->prepare($query); |
|
146 |
$this->stmt->execute(); |
|
147 |
$result = $this->stmt->fetchAll(); |
|
148 |
$result[0]["max"]+=1; |
|
149 |
|
|
150 |
$query = "INSERT INTO dd_lemma ( id, "; |
|
151 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
152 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
153 |
$query .= " lemma, "; |
|
154 |
$values .= " :lemma, "; |
|
155 |
} |
|
156 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
157 |
$query .= " pos ) "; |
|
158 |
$values .= " :pos ); "; |
|
159 |
} |
|
160 |
|
|
161 |
$query .= $values; |
|
162 |
$this->stmt = $this->pdo->prepare($query); |
|
163 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
164 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
165 |
} |
|
166 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
167 |
$this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT); |
|
168 |
} |
|
169 |
$this->stmt->execute(); |
|
170 |
|
|
121 |
function update(){ |
|
171 | 122 |
$query = "SELECT id FROM dd_lemma |
172 | 123 |
WHERE lemma = :lemma;"; |
173 | 124 |
$this->stmt = $this->pdo->prepare($query); |
... | ... | |
176 | 127 |
} |
177 | 128 |
$this->stmt->execute(); |
178 | 129 |
$lemma = $this->stmt->fetch(PDO::FETCH_ASSOC); |
179 |
} |
|
180 |
|
|
181 |
$query = "UPDATE dd_lemma |
|
182 |
SET "; |
|
183 |
|
|
184 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
185 |
$query .= " lemma = :lemma , "; |
|
186 |
} |
|
187 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
188 |
$query .= " pos = :pos "; |
|
189 |
} |
|
190 |
|
|
191 |
$query .= "WHERE "; |
|
192 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
193 |
$query .= " id = :lemma_id ;"; |
|
194 |
} |
|
195 |
|
|
196 |
|
|
197 |
$this->stmt = $this->pdo->prepare($query); |
|
198 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
199 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
200 |
} |
|
201 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
202 |
$this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT); |
|
203 |
} |
|
204 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
205 |
$this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT); |
|
206 |
} |
|
207 |
$this->stmt->execute(); |
|
208 |
|
|
209 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
210 |
if($tag == null){ |
|
211 |
$query = "SELECT MAX(id) FROM dd_tag;"; |
|
212 |
$this->stmt = $this->pdo->prepare($query); |
|
213 |
$this->stmt->execute(); |
|
214 |
$result = $this->stmt->fetchAll(); |
|
215 |
$result[0]["max"]+=1; |
|
216 |
|
|
217 |
|
|
218 |
$query = "INSERT INTO dd_tag (id, "; |
|
219 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
220 |
|
|
221 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
222 |
$query .= " tag ) "; |
|
223 |
$values .= " :tag ); "; |
|
224 |
} |
|
225 |
|
|
226 |
$query .= $values; |
|
227 |
$this->stmt = $this->pdo->prepare($query); |
|
228 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
229 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
230 |
} |
|
231 |
$this->stmt->execute(); |
|
232 | 130 |
|
233 | 131 |
$query = "SELECT id FROM dd_tag |
234 | 132 |
WHERE tag = :tag;"; |
... | ... | |
238 | 136 |
} |
239 | 137 |
$this->stmt->execute(); |
240 | 138 |
$tag = $this->stmt->fetch(PDO::FETCH_ASSOC); |
241 |
} |
|
242 |
|
|
243 |
$query = "UPDATE dd_tag |
|
244 |
SET "; |
|
245 |
|
|
246 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
247 |
$query .= " tag = :tag "; |
|
248 |
} |
|
249 |
|
|
250 |
$query .= "WHERE "; |
|
251 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
252 |
$query .= " id = :tag_id ;"; |
|
253 |
} |
|
254 |
|
|
255 |
|
|
256 |
$this->stmt = $this->pdo->prepare($query); |
|
257 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
258 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
259 |
} |
|
260 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
261 |
$this->stmt->bindParam(':tag_id', $tag["id"], PDO::PARAM_INT); |
|
262 |
} |
|
263 |
$this->stmt->execute(); |
|
264 |
|
|
265 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
266 |
$query = "UPDATE dd_wordform |
|
267 |
SET "; |
|
268 |
|
|
269 |
|
|
270 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") { |
|
271 |
$query .= " context = :context, "; |
|
272 |
} |
|
273 |
$query .= " date = CURRENT_DATE,"; |
|
274 |
|
|
275 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") { |
|
276 |
$query .= " description = :description, "; |
|
277 |
} |
|
278 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") { |
|
279 |
$query .= " description2 = :description2, "; |
|
280 |
} |
|
281 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") { |
|
282 |
$query .= " description3 = :description3, "; |
|
283 |
} |
|
284 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") { |
|
285 |
$query .= " ending = :ending, "; |
|
286 |
} |
|
287 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") { |
|
288 |
$query .= " finished = :finished, "; |
|
289 |
} |
|
290 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") { |
|
291 |
$query .= " namedentity = :namedentity, "; |
|
292 |
} |
|
293 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") { |
|
294 |
$query .= " position1 = :position1, "; |
|
295 |
} |
|
296 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") { |
|
297 |
$query .= " position2 = :position2, "; |
|
298 |
} |
|
299 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") { |
|
300 |
$query .= " positiondetail = :positiondetail ,"; |
|
301 |
} |
|
302 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") { |
|
303 |
$query .= " prefix = :prefix, "; |
|
304 |
} |
|
305 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") { |
|
306 |
$query .= " suffix = :suffix, "; |
|
307 |
} |
|
308 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") { |
|
309 |
$query .= " word = :word, "; |
|
310 |
} |
|
311 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
312 |
$query .= " lemma_id = :lemma_id, "; |
|
313 |
} |
|
314 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
315 |
$query .= " tag_id = :tag_id "; |
|
316 |
} |
|
317 | 139 |
|
318 |
$query .= " WHERE "; |
|
319 |
if (array_key_exists("id", $_POST) && $_POST['id'] != "") { |
|
320 |
$query .= " id = :id ;"; |
|
321 |
} |
|
322 |
|
|
323 |
$this->stmt = $this->pdo->prepare($query); |
|
324 |
|
|
325 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") { |
|
326 |
$this->stmt->bindParam(':context', $_POST['context'], PDO::PARAM_STR); |
|
327 |
} |
|
328 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") { |
|
329 |
$this->stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR); |
|
330 |
} |
|
331 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") { |
|
332 |
$this->stmt->bindParam(':description2', $_POST['description2'], PDO::PARAM_STR); |
|
333 |
} |
|
334 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") { |
|
335 |
$this->stmt->bindParam(':description3', $_POST['description3'], PDO::PARAM_STR); |
|
336 |
} |
|
337 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") { |
|
338 |
$this->stmt->bindParam(':ending', $_POST['ending'], PDO::PARAM_STR); |
|
339 |
} |
|
340 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") { |
|
341 |
$this->stmt->bindParam(':finished', $_POST['finished']); |
|
342 |
} |
|
343 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") { |
|
344 |
$this->stmt->bindParam(':namedentity', $_POST['namedentity'], PDO::PARAM_INT); |
|
345 |
} |
|
346 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") { |
|
347 |
$this->stmt->bindParam(':position1', $_POST['position1'], PDO::PARAM_STR); |
|
348 |
} |
|
349 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") { |
|
350 |
$this->stmt->bindParam(':position2', $_POST['position2'], PDO::PARAM_STR); |
|
351 |
} |
|
352 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") { |
|
353 |
$this->stmt->bindParam(':positiondetail', $_POST['positiondetail'], PDO::PARAM_STR); |
|
354 |
} |
|
355 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") { |
|
356 |
$this->stmt->bindParam(':prefix', $_POST['prefix'], PDO::PARAM_STR); |
|
357 |
} |
|
358 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") { |
|
359 |
$this->stmt->bindParam(':suffix', $_POST['suffix'], PDO::PARAM_STR); |
|
360 |
} |
|
361 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") { |
|
362 |
$this->stmt->bindParam(':word', $_POST['word'], PDO::PARAM_STR); |
|
363 |
} |
|
364 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
365 |
$this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT); |
|
366 |
} |
|
367 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
368 |
$this->stmt->bindParam(':tag_id', $tag["id"], PDO::PARAM_INT); |
|
369 |
} |
|
370 |
if (array_key_exists("id", $_POST) && $_POST['id'] != "") { |
|
371 |
$this->stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT); |
|
372 |
} |
|
373 |
|
|
374 |
$this->stmt->execute(); |
|
140 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
141 |
if($lemma == null){ |
|
142 |
$query = "SELECT MAX(id) FROM dd_lemma;"; |
|
143 |
$this->stmt = $this->pdo->prepare($query); |
|
144 |
$this->stmt->execute(); |
|
145 |
$result = $this->stmt->fetchAll(); |
|
146 |
$result[0]["max"]+=1; |
|
375 | 147 |
|
376 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
148 |
$query = "INSERT INTO dd_lemma ( id, "; |
|
149 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
150 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
151 |
$query .= " lemma, "; |
|
152 |
$values .= " :lemma, "; |
|
153 |
} |
|
154 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
155 |
$query .= " pos ) "; |
|
156 |
$values .= " :pos ); "; |
|
157 |
} |
|
377 | 158 |
|
378 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
379 |
$query = "SELECT * FROM dd_manuscript WHERE "; |
|
380 |
$query .= " wordform_id = :wordform_id ;"; |
|
381 |
} |
|
159 |
$query .= $values; |
|
160 |
$this->stmt = $this->pdo->prepare($query); |
|
161 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
162 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
163 |
} |
|
164 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
165 |
$this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT); |
|
166 |
} |
|
167 |
$this->stmt->execute(); |
|
382 | 168 |
|
383 |
$this->stmt = $this->pdo->prepare($query); |
|
384 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
385 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
386 |
} |
|
387 |
$this->stmt->execute(); |
|
388 |
$result = $this->stmt->fetchAll(); |
|
169 |
$query = "SELECT id FROM dd_lemma |
|
170 |
WHERE lemma = :lemma;"; |
|
171 |
$this->stmt = $this->pdo->prepare($query); |
|
172 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
173 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
174 |
} |
|
175 |
$this->stmt->execute(); |
|
176 |
$lemma = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
177 |
} |
|
389 | 178 |
|
390 |
$to_insert = []; |
|
391 |
$to_delete = []; |
|
392 |
$contained = []; |
|
393 |
$found = false; |
|
394 |
$integerIDs = []; |
|
179 |
$query = "UPDATE dd_lemma |
|
180 |
SET "; |
|
395 | 181 |
|
396 |
foreach ($result as $res) { |
|
397 |
$integerIDs = array_map('intval', explode(',', $_POST['manuscript'])); |
|
398 |
foreach ($integerIDs as $new_value){ |
|
399 |
if($new_value == $res['manuscript']){ |
|
400 |
$found = true; |
|
401 |
array_push($contained, $new_value); |
|
402 |
} |
|
182 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
183 |
$query .= " lemma = :lemma , "; |
|
403 | 184 |
} |
404 |
if($found == false){
|
|
405 |
array_push($to_delete, $res);
|
|
185 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") {
|
|
186 |
$query .= " pos = :pos ";
|
|
406 | 187 |
} |
407 |
$found = false; |
|
408 |
} |
|
409 |
$to_insert = array_diff($integerIDs, $contained); |
|
410 | 188 |
|
411 |
foreach ($to_delete as $id_to_delete){
|
|
412 |
$query = "DELETE FROM dd_manuscript WHERE ";
|
|
413 |
$query .= "manuscript = " . $id_to_delete['manuscript'] . " AND ";
|
|
414 |
$query .= " wordform_id = :wordform_id ;";
|
|
189 |
$query .= "WHERE ";
|
|
190 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
|
|
191 |
$query .= " id = :lemma_id ;";
|
|
192 |
}
|
|
415 | 193 |
|
416 | 194 |
|
417 | 195 |
$this->stmt = $this->pdo->prepare($query); |
418 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
419 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
196 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
197 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
198 |
} |
|
199 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
200 |
$this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT); |
|
201 |
} |
|
202 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
203 |
$this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT); |
|
420 | 204 |
} |
421 |
// |
|
422 | 205 |
$this->stmt->execute(); |
423 |
var_dump($query); |
|
424 |
} |
|
425 | 206 |
|
426 |
foreach ($to_insert as $id_to_insert){ |
|
427 |
$query = "INSERT INTO dd_manuscript VALUES ( "; |
|
428 |
$query .= " :wordform_id , "; |
|
429 |
$query .= " " . $id_to_insert . " ); "; |
|
207 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
208 |
if($tag == null){ |
|
209 |
$query = "SELECT MAX(id) FROM dd_tag;"; |
|
210 |
$this->stmt = $this->pdo->prepare($query); |
|
211 |
$this->stmt->execute(); |
|
212 |
$result = $this->stmt->fetchAll(); |
|
213 |
$result[0]["max"]+=1; |
|
430 | 214 |
|
431 |
$this->stmt = $this->pdo->prepare($query); |
|
432 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
433 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
434 |
} |
|
435 |
$this->stmt->execute(); |
|
436 |
} |
|
437 |
} |
|
438 | 215 |
|
439 |
function insert(){ |
|
440 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
441 |
$query = "SELECT id FROM dd_lemma |
|
442 |
WHERE lemma = :lemma;"; |
|
443 |
$this->stmt = $this->pdo->prepare($query); |
|
444 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
445 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
446 |
} |
|
447 |
$this->stmt->execute(); |
|
448 |
$lemma = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
216 |
$query = "INSERT INTO dd_tag (id, "; |
|
217 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
449 | 218 |
|
450 |
if($lemma == null){ |
|
451 |
$query = "SELECT MAX(id) FROM dd_lemma;"; |
|
452 |
$this->stmt = $this->pdo->prepare($query); |
|
453 |
$this->stmt->execute(); |
|
454 |
$result = $this->stmt->fetchAll(); |
|
455 |
$result[0]["max"]+=1; |
|
219 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
220 |
$query .= " tag ) "; |
|
221 |
$values .= " :tag ); "; |
|
222 |
} |
|
456 | 223 |
|
457 |
$query = "INSERT INTO dd_lemma ( id, "; |
|
458 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
459 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
460 |
$query .= " lemma, "; |
|
461 |
$values .= " :lemma, "; |
|
462 |
} |
|
463 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
464 |
$query .= " pos ) "; |
|
465 |
$values .= " :pos ); "; |
|
466 |
} |
|
224 |
$query .= $values; |
|
225 |
$this->stmt = $this->pdo->prepare($query); |
|
226 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
227 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
228 |
} |
|
229 |
$this->stmt->execute(); |
|
467 | 230 |
|
468 |
$query .= $values; |
|
469 |
$this->stmt = $this->pdo->prepare($query); |
|
470 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
471 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
472 |
} |
|
473 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
474 |
$this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT); |
|
475 |
} |
|
476 |
$this->stmt->execute(); |
|
477 |
} |
|
231 |
$query = "SELECT id FROM dd_tag |
|
232 |
WHERE tag = :tag;"; |
|
233 |
$this->stmt = $this->pdo->prepare($query); |
|
234 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
235 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
236 |
} |
|
237 |
$this->stmt->execute(); |
|
238 |
$tag = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
239 |
} |
|
478 | 240 |
|
241 |
$query = "UPDATE dd_tag |
|
242 |
SET "; |
|
479 | 243 |
|
244 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
245 |
$query .= " tag = :tag "; |
|
246 |
} |
|
480 | 247 |
|
481 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
482 |
$query = "SELECT id FROM dd_tag |
|
483 |
WHERE tag = :tag;"; |
|
484 |
$this->stmt = $this->pdo->prepare($query); |
|
248 |
$query .= "WHERE "; |
|
485 | 249 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
486 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR);
|
|
250 |
$query .= " id = :tag_id ;";
|
|
487 | 251 |
} |
488 |
$this->stmt->execute(); |
|
489 |
$tag = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
490 | 252 |
|
491 |
if($tag == null){ |
|
492 |
$query = "SELECT MAX(id) FROM dd_tag;"; |
|
253 |
|
|
493 | 254 |
$this->stmt = $this->pdo->prepare($query); |
255 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
256 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
257 |
} |
|
258 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
259 |
$this->stmt->bindParam(':tag_id', $tag["id"], PDO::PARAM_INT); |
|
260 |
} |
|
494 | 261 |
$this->stmt->execute(); |
495 |
$result = $this->stmt->fetchAll(); |
|
496 |
$result[0]["max"]+=1; |
|
497 | 262 |
|
263 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
264 |
$query = "UPDATE dd_wordform |
|
265 |
SET "; |
|
498 | 266 |
|
499 |
$query = "INSERT INTO dd_tag (id, "; |
|
500 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
501 | 267 |
|
502 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
503 |
$query .= " tag ) "; |
|
504 |
$values .= " :tag ); "; |
|
505 |
} |
|
506 |
|
|
507 |
$query .= $values; |
|
508 |
$this->stmt = $this->pdo->prepare($query); |
|
509 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
510 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
511 |
} |
|
512 |
$this->stmt->execute(); |
|
513 |
} |
|
268 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") { |
|
269 |
$query .= " context = :context, "; |
|
270 |
} |
|
271 |
$query .= " date = CURRENT_DATE,"; |
|
514 | 272 |
|
515 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
516 |
$query = "SELECT MAX(id) FROM dd_wordform;"; |
|
517 |
$this->stmt = $this->pdo->prepare($query); |
|
518 |
$this->stmt->execute(); |
|
519 |
$result = $this->stmt->fetchAll(); |
|
520 |
$result[0]["max"]+=1; |
|
521 |
|
|
522 |
$query = "SELECT id FROM dd_lemma |
|
523 |
WHERE lemma = :lemma;"; |
|
524 |
$this->stmt = $this->pdo->prepare($query); |
|
273 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") { |
|
274 |
$query .= " description = :description, "; |
|
275 |
} |
|
276 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") { |
|
277 |
$query .= " description2 = :description2, "; |
|
278 |
} |
|
279 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") { |
|
280 |
$query .= " description3 = :description3, "; |
|
281 |
} |
|
282 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") { |
|
283 |
$query .= " ending = :ending, "; |
|
284 |
} |
|
285 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") { |
|
286 |
$query .= " finished = :finished, "; |
|
287 |
} |
|
288 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") { |
|
289 |
$query .= " namedentity = :namedentity, "; |
|
290 |
} |
|
291 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") { |
|
292 |
$query .= " position1 = :position1, "; |
|
293 |
} |
|
294 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") { |
|
295 |
$query .= " position2 = :position2, "; |
|
296 |
} |
|
297 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") { |
|
298 |
$query .= " positiondetail = :positiondetail ,"; |
|
299 |
} |
|
300 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") { |
|
301 |
$query .= " prefix = :prefix, "; |
|
302 |
} |
|
303 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") { |
|
304 |
$query .= " suffix = :suffix, "; |
|
305 |
} |
|
306 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") { |
|
307 |
$query .= " word = :word, "; |
|
308 |
} |
|
525 | 309 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
526 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR);
|
|
310 |
$query .= " lemma_id = :lemma_id, ";
|
|
527 | 311 |
} |
528 |
$this->stmt->execute(); |
|
529 |
$lemma = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
530 |
|
|
531 |
$query = "SELECT id FROM dd_tag |
|
532 |
WHERE tag = :tag;"; |
|
533 |
$this->stmt = $this->pdo->prepare($query); |
|
534 | 312 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
535 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR);
|
|
313 |
$query .= " tag_id = :tag_id ";
|
|
536 | 314 |
} |
537 |
$this->stmt->execute(); |
|
538 |
$tag = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
539 |
|
|
540 |
$query = "INSERT INTO dd_wordform ( id, "; |
|
541 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
542 | 315 |
|
543 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") {
|
|
544 |
$query .= " context, ";
|
|
545 |
$values .= " :context, ";
|
|
316 |
$query .= " WHERE ";
|
|
317 |
if (array_key_exists("id", $_POST) && $_POST['id'] != "") {
|
|
318 |
$query .= " id = :id ;";
|
|
546 | 319 |
} |
547 |
$query .= " date, "; |
|
548 |
$values .= " CURRENT_DATE, "; |
|
549 | 320 |
|
321 |
$this->stmt = $this->pdo->prepare($query); |
|
322 |
|
|
323 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") { |
|
324 |
$this->stmt->bindParam(':context', $_POST['context'], PDO::PARAM_STR); |
|
325 |
} |
|
550 | 326 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") { |
551 |
$query .= " description, "; |
|
552 |
$values .= " :description, "; |
|
327 |
$this->stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR); |
|
553 | 328 |
} |
554 | 329 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") { |
555 |
$query .= " description2, "; |
|
556 |
$values .= " :description2, "; |
|
330 |
$this->stmt->bindParam(':description2', $_POST['description2'], PDO::PARAM_STR); |
|
557 | 331 |
} |
558 | 332 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") { |
559 |
$query .= " description3, "; |
|
560 |
$values .= " :description3, "; |
|
333 |
$this->stmt->bindParam(':description3', $_POST['description3'], PDO::PARAM_STR); |
|
561 | 334 |
} |
562 | 335 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") { |
563 |
$query .= " ending, "; |
|
564 |
$values .= " :ending, "; |
|
336 |
$this->stmt->bindParam(':ending', $_POST['ending'], PDO::PARAM_STR); |
|
565 | 337 |
} |
566 | 338 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") { |
567 |
$query .= " finished, "; |
|
568 |
$values .= " :finished, "; |
|
339 |
$this->stmt->bindParam(':finished', $_POST['finished']); |
|
569 | 340 |
} |
570 | 341 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") { |
571 |
$query .= " namedentity, "; |
|
572 |
$values .= " :namedentity, "; |
|
342 |
$this->stmt->bindParam(':namedentity', $_POST['namedentity'], PDO::PARAM_INT); |
|
573 | 343 |
} |
574 | 344 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") { |
575 |
$query .= " position1, "; |
|
576 |
$values .= " :position1, "; |
|
345 |
$this->stmt->bindParam(':position1', $_POST['position1'], PDO::PARAM_STR); |
|
577 | 346 |
} |
578 | 347 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") { |
579 |
$query .= " position2, "; |
|
580 |
$values .= " :position2, "; |
|
348 |
$this->stmt->bindParam(':position2', $_POST['position2'], PDO::PARAM_STR); |
|
581 | 349 |
} |
582 | 350 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") { |
583 |
$query .= " positiondetail, "; |
|
584 |
$values .= " :positiondetail, "; |
|
351 |
$this->stmt->bindParam(':positiondetail', $_POST['positiondetail'], PDO::PARAM_STR); |
|
585 | 352 |
} |
586 | 353 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") { |
587 |
$query .= " prefix, "; |
|
588 |
$values .= " :prefix, "; |
|
354 |
$this->stmt->bindParam(':prefix', $_POST['prefix'], PDO::PARAM_STR); |
|
589 | 355 |
} |
590 | 356 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") { |
591 |
$query .= " suffix, "; |
|
592 |
$values .= " :suffix, "; |
|
357 |
$this->stmt->bindParam(':suffix', $_POST['suffix'], PDO::PARAM_STR); |
|
593 | 358 |
} |
594 | 359 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") { |
595 |
$query .= " word, "; |
|
596 |
$values .= " :word, "; |
|
360 |
$this->stmt->bindParam(':word', $_POST['word'], PDO::PARAM_STR); |
|
597 | 361 |
} |
598 | 362 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
599 |
$query .= " lemma_id, "; |
|
600 |
$values .= " :lemma_id, "; |
|
363 |
$this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT); |
|
601 | 364 |
} |
602 | 365 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
603 |
$query .= " tag_id ) "; |
|
604 |
$values .= " :tag_id ); "; |
|
366 |
$this->stmt->bindParam(':tag_id', $tag["id"], PDO::PARAM_INT); |
|
367 |
} |
|
368 |
if (array_key_exists("id", $_POST) && $_POST['id'] != "") { |
|
369 |
$this->stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT); |
|
370 |
} |
|
371 |
|
|
372 |
$this->stmt->execute(); |
|
373 |
|
|
374 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
375 |
|
|
376 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
377 |
$query = "SELECT * FROM dd_manuscript WHERE "; |
|
378 |
$query .= " wordform_id = :wordform_id ;"; |
|
379 |
} |
|
380 |
|
|
381 |
$this->stmt = $this->pdo->prepare($query); |
|
382 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
383 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
384 |
} |
|
385 |
$this->stmt->execute(); |
|
386 |
$result = $this->stmt->fetchAll(); |
|
387 |
|
|
388 |
$to_insert = []; |
|
389 |
$to_delete = []; |
|
390 |
$contained = []; |
|
391 |
$found = false; |
|
392 |
$integerIDs = []; |
|
393 |
|
|
394 |
foreach ($result as $res) { |
|
395 |
$integerIDs = array_map('intval', explode(',', $_POST['manuscript'])); |
|
396 |
foreach ($integerIDs as $new_value){ |
|
397 |
if($new_value == $res['manuscript']){ |
|
398 |
$found = true; |
|
399 |
array_push($contained, $new_value); |
|
400 |
} |
|
401 |
} |
|
402 |
if($found == false){ |
|
403 |
array_push($to_delete, $res); |
|
404 |
} |
|
405 |
$found = false; |
|
406 |
} |
|
407 |
$to_insert = array_diff($integerIDs, $contained); |
|
408 |
|
|
409 |
foreach ($to_delete as $id_to_delete){ |
|
410 |
$query = "DELETE FROM dd_manuscript WHERE "; |
|
411 |
$query .= "manuscript = " . $id_to_delete['manuscript'] . " AND "; |
|
412 |
$query .= " wordform_id = :wordform_id ;"; |
|
413 |
|
|
414 |
|
|
415 |
$this->stmt = $this->pdo->prepare($query); |
|
416 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
417 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
418 |
} |
|
419 |
// |
|
420 |
$this->stmt->execute(); |
|
421 |
var_dump($query); |
|
422 |
} |
|
423 |
|
|
424 |
foreach ($to_insert as $id_to_insert){ |
|
425 |
$query = "INSERT INTO dd_manuscript VALUES ( "; |
|
426 |
$query .= " :wordform_id , "; |
|
427 |
$query .= " " . $id_to_insert . " ); "; |
|
428 |
|
|
429 |
$this->stmt = $this->pdo->prepare($query); |
|
430 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
431 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
432 |
} |
|
433 |
$this->stmt->execute(); |
|
434 |
} |
|
435 |
} |
|
436 |
|
|
437 |
function insert(){ |
|
438 |
print_r($_POST); |
|
439 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
440 |
$query = "SELECT id FROM dd_lemma |
|
441 |
WHERE lemma = :lemma;"; |
|
442 |
$this->stmt = $this->pdo->prepare($query); |
|
443 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
444 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
445 |
} |
|
446 |
$this->stmt->execute(); |
|
447 |
$lemma = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
448 |
|
|
449 |
if($lemma == null){ |
|
450 |
$query = "SELECT MAX(id) FROM dd_lemma;"; |
|
451 |
$this->stmt = $this->pdo->prepare($query); |
|
452 |
$this->stmt->execute(); |
|
453 |
$result = $this->stmt->fetchAll(); |
|
454 |
$result[0]["max"]+=1; |
|
455 |
|
|
456 |
$query = "INSERT INTO dd_lemma ( id, "; |
|
457 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
458 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
459 |
$query .= " lemma, "; |
|
460 |
$values .= " :lemma, "; |
|
461 |
} |
|
462 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
463 |
$query .= " pos ) "; |
|
464 |
$values .= " :pos ); "; |
|
465 |
} |
|
466 |
|
|
467 |
$query .= $values; |
|
468 |
$this->stmt = $this->pdo->prepare($query); |
|
469 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
470 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
471 |
} |
|
472 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") { |
|
473 |
$this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT); |
|
474 |
} |
|
475 |
$this->stmt->execute(); |
|
476 |
} |
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
481 |
$query = "SELECT id FROM dd_tag |
|
482 |
WHERE tag = :tag;"; |
|
483 |
$this->stmt = $this->pdo->prepare($query); |
|
484 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
485 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
486 |
} |
|
487 |
$this->stmt->execute(); |
|
488 |
$tag = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
489 |
|
|
490 |
if($tag == null){ |
|
491 |
$query = "SELECT MAX(id) FROM dd_tag;"; |
|
492 |
$this->stmt = $this->pdo->prepare($query); |
|
493 |
$this->stmt->execute(); |
|
494 |
$result = $this->stmt->fetchAll(); |
|
495 |
$result[0]["max"]+=1; |
|
496 |
|
|
497 |
|
|
498 |
$query = "INSERT INTO dd_tag (id, "; |
|
499 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
500 |
|
|
501 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
502 |
$query .= " tag ) "; |
|
503 |
$values .= " :tag ); "; |
|
504 |
} |
|
505 |
|
|
506 |
$query .= $values; |
|
507 |
$this->stmt = $this->pdo->prepare($query); |
|
508 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
509 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
510 |
} |
|
511 |
$this->stmt->execute(); |
|
605 | 512 |
} |
606 | 513 |
|
607 |
$query .= $values; |
|
514 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
515 |
$query = "SELECT MAX(id) FROM dd_wordform;"; |
|
608 | 516 |
$this->stmt = $this->pdo->prepare($query); |
517 |
$this->stmt->execute(); |
|
518 |
$result = $this->stmt->fetchAll(); |
|
519 |
$result[0]["max"]+=1; |
|
609 | 520 |
|
610 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") { |
|
611 |
$this->stmt->bindParam(':context', $_POST['context'], PDO::PARAM_STR); |
|
521 |
$query = "SELECT id FROM dd_lemma |
|
522 |
WHERE lemma = :lemma;"; |
|
523 |
$this->stmt = $this->pdo->prepare($query); |
|
524 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
525 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR); |
|
612 | 526 |
} |
527 |
$this->stmt->execute(); |
|
528 |
$lemma = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
529 |
|
|
530 |
$query = "SELECT id FROM dd_tag |
|
531 |
WHERE tag = :tag;"; |
|
532 |
$this->stmt = $this->pdo->prepare($query); |
|
533 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
534 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR); |
|
535 |
} |
|
536 |
$this->stmt->execute(); |
|
537 |
$tag = $this->stmt->fetch(PDO::FETCH_ASSOC); |
|
538 |
|
|
539 |
$query = "INSERT INTO dd_wordform ( id, "; |
|
540 |
$values = "VALUES (" . $result[0]["max"] . ", "; |
|
541 |
|
|
542 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") { |
|
543 |
$query .= " context, "; |
|
544 |
$values .= " :context, "; |
|
545 |
} |
|
546 |
$query .= " date, "; |
|
547 |
$values .= " CURRENT_DATE, "; |
|
548 |
|
|
613 | 549 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") { |
614 |
$this->stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR); |
|
550 |
$query .= " description, "; |
|
551 |
$values .= " :description, "; |
|
615 | 552 |
} |
616 | 553 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") { |
617 |
$this->stmt->bindParam(':description2', $_POST['description2'], PDO::PARAM_STR); |
|
554 |
$query .= " description2, "; |
|
555 |
$values .= " :description2, "; |
|
618 | 556 |
} |
619 | 557 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") { |
620 |
$this->stmt->bindParam(':description3', $_POST['description3'], PDO::PARAM_STR); |
|
558 |
$query .= " description3, "; |
|
559 |
$values .= " :description3, "; |
|
621 | 560 |
} |
622 | 561 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") { |
623 |
$this->stmt->bindParam(':ending', $_POST['ending'], PDO::PARAM_STR); |
|
562 |
$query .= " ending, "; |
|
563 |
$values .= " :ending, "; |
|
624 | 564 |
} |
625 | 565 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") { |
626 |
$this->stmt->bindParam(':finished', $_POST['finished']); |
|
566 |
$query .= " finished, "; |
|
567 |
$values .= " :finished, "; |
|
627 | 568 |
} |
628 | 569 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") { |
629 |
$this->stmt->bindParam(':namedentity', $_POST['namedentity'], PDO::PARAM_INT); |
|
570 |
$query .= " namedentity, "; |
|
571 |
$values .= " :namedentity, "; |
|
630 | 572 |
} |
631 | 573 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") { |
632 |
$this->stmt->bindParam(':position1', $_POST['position1'], PDO::PARAM_STR); |
|
574 |
$query .= " position1, "; |
|
575 |
$values .= " :position1, "; |
|
633 | 576 |
} |
634 | 577 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") { |
635 |
$this->stmt->bindParam(':position2', $_POST['position2'], PDO::PARAM_STR); |
|
578 |
$query .= " position2, "; |
|
579 |
$values .= " :position2, "; |
|
636 | 580 |
} |
637 | 581 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") { |
638 |
$this->stmt->bindParam(':positiondetail', $_POST['positiondetail'], PDO::PARAM_STR); |
|
582 |
$query .= " positiondetail, "; |
|
583 |
$values .= " :positiondetail, "; |
|
639 | 584 |
} |
640 | 585 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") { |
641 |
$this->stmt->bindParam(':prefix', $_POST['prefix'], PDO::PARAM_STR); |
|
586 |
$query .= " prefix, "; |
|
587 |
$values .= " :prefix, "; |
|
642 | 588 |
} |
643 | 589 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") { |
644 |
$this->stmt->bindParam(':suffix', $_POST['suffix'], PDO::PARAM_STR); |
|
590 |
$query .= " suffix, "; |
|
591 |
$values .= " :suffix, "; |
|
645 | 592 |
} |
646 | 593 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") { |
647 |
$this->stmt->bindParam(':word', $_POST['word'], PDO::PARAM_STR); |
|
594 |
$query .= " word, "; |
|
595 |
$values .= " :word, "; |
|
648 | 596 |
} |
649 | 597 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
650 |
$this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT); |
|
598 |
$query .= " lemma_id, "; |
|
599 |
$values .= " :lemma_id, "; |
|
651 | 600 |
} |
652 | 601 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
653 |
$this->stmt->bindParam(':tag_id', $tag["id"], PDO::PARAM_INT); |
|
602 |
$query .= " tag_id ) "; |
|
603 |
$values .= " :tag_id ); "; |
|
654 | 604 |
} |
655 | 605 |
|
656 |
$this->stmt->execute(); |
|
606 |
$query .= $values; |
|
607 |
$this->stmt = $this->pdo->prepare($query); |
|
657 | 608 |
|
609 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") { |
|
610 |
$this->stmt->bindParam(':context', $_POST['context'], PDO::PARAM_STR); |
|
611 |
} |
|
612 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") { |
|
613 |
$this->stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR); |
|
614 |
} |
|
615 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") { |
|
616 |
$this->stmt->bindParam(':description2', $_POST['description2'], PDO::PARAM_STR); |
|
617 |
} |
|
618 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") { |
|
619 |
$this->stmt->bindParam(':description3', $_POST['description3'], PDO::PARAM_STR); |
|
620 |
} |
|
621 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") { |
|
622 |
$this->stmt->bindParam(':ending', $_POST['ending'], PDO::PARAM_STR); |
|
623 |
} |
|
624 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") { |
|
625 |
$this->stmt->bindParam(':finished', $_POST['finished']); |
|
626 |
} |
|
627 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") { |
|
628 |
$this->stmt->bindParam(':namedentity', $_POST['namedentity'], PDO::PARAM_INT); |
|
629 |
} |
|
630 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") { |
|
631 |
$this->stmt->bindParam(':position1', $_POST['position1'], PDO::PARAM_STR); |
|
632 |
} |
|
633 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") { |
|
634 |
$this->stmt->bindParam(':position2', $_POST['position2'], PDO::PARAM_STR); |
|
635 |
} |
|
636 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") { |
|
637 |
$this->stmt->bindParam(':positiondetail', $_POST['positiondetail'], PDO::PARAM_STR); |
|
638 |
} |
|
639 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") { |
|
640 |
$this->stmt->bindParam(':prefix', $_POST['prefix'], PDO::PARAM_STR); |
|
641 |
} |
|
642 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") { |
|
643 |
$this->stmt->bindParam(':suffix', $_POST['suffix'], PDO::PARAM_STR); |
|
644 |
} |
|
645 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") { |
|
646 |
$this->stmt->bindParam(':word', $_POST['word'], PDO::PARAM_STR); |
|
647 |
} |
|
648 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
649 |
$this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT); |
|
650 |
} |
|
651 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
652 |
$this->stmt->bindParam(':tag_id', $tag["id"], PDO::PARAM_INT); |
|
653 |
} |
|
658 | 654 |
|
659 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
655 |
$this->stmt->execute();
|
|
660 | 656 |
|
661 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
662 |
$query = "SELECT * FROM dd_manuscript WHERE "; |
|
663 |
$query .= " wordform_id = :wordform_id ;"; |
|
664 | 657 |
|
665 |
$this->stmt = $this->pdo->prepare($query); |
|
666 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
667 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
668 |
} |
|
669 |
$this->stmt->execute(); |
|
670 |
$result = $this->stmt->fetchAll(); |
|
658 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
671 | 659 |
|
672 |
$to_insert = []; |
|
673 |
$contained = []; |
|
674 |
$found = false; |
|
675 |
$integerIDs = []; |
|
676 |
|
|
677 |
foreach ($result as $res) { |
|
678 |
$integerIDs = array_map('intval', explode(',', $_POST['manuscript'])); |
|
679 |
foreach ($integerIDs as $new_value){ |
|
680 |
if($new_value == $res['manuscript']){ |
|
681 |
$found = true; |
|
682 |
array_push($contained, $new_value); |
|
683 |
} |
|
684 |
} |
|
685 |
if($found == false){ |
|
686 |
array_push($to_delete, $res); |
|
687 |
} |
|
688 |
$found = false; |
|
689 |
} |
|
690 |
$to_insert = array_diff($integerIDs, $contained); |
|
691 |
foreach ($to_insert as $id_to_insert){ |
|
692 |
$query = "INSERT INTO dd_manuscript VALUES ( "; |
|
693 |
$query .= " :wordform_id , "; |
|
694 |
$query .= " " . $id_to_insert . " ); "; |
|
660 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
661 |
$query = "SELECT * FROM dd_manuscript WHERE "; |
|
662 |
$query .= " wordform_id = :wordform_id ;"; |
|
695 | 663 |
|
696 |
$this->stmt = $this->pdo->prepare($query);
|
|
664 |
$this->stmt = $this->pdo->prepare($query); |
|
697 | 665 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
698 | 666 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
699 | 667 |
} |
700 | 668 |
$this->stmt->execute(); |
701 |
} |
|
702 |
} |
|
669 |
$result = $this->stmt->fetchAll(); |
|
670 |
|
|
671 |
$to_insert = []; |
|
672 |
$contained = []; |
|
673 |
$found = false; |
|
674 |
$integerIDs = []; |
|
675 |
|
|
676 |
foreach ($result as $res) { |
|
677 |
$integerIDs = array_map('intval', explode(',', $_POST['manuscript'])); |
|
678 |
foreach ($integerIDs as $new_value){ |
|
679 |
if($new_value == $res['manuscript']){ |
|
680 |
$found = true; |
|
681 |
array_push($contained, $new_value); |
|
682 |
} |
|
683 |
} |
|
684 |
if($found == false){ |
|
685 |
array_push($to_delete, $res); |
|
686 |
} |
|
687 |
$found = false; |
|
688 |
} |
|
689 |
$to_insert = array_diff($integerIDs, $contained); |
|
690 |
foreach ($to_insert as $id_to_insert){ |
|
691 |
$query = "INSERT INTO dd_manuscript VALUES ( "; |
|
692 |
$query .= " :wordform_id , "; |
|
693 |
$query .= " " . $id_to_insert . " ); "; |
|
694 |
|
|
695 |
$this->stmt = $this->pdo->prepare($query); |
|
696 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
697 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
698 |
} |
|
699 |
$this->stmt->execute(); |
|
700 |
} |
|
701 |
} |
|
703 | 702 |
|
704 | 703 |
|
705 |
} |
|
704 |
}
|
|
706 | 705 |
|
707 | 706 |
|
708 | 707 |
} |
Také k dispozici: Unified diff
Feature #8727: Návrh změn záznamů - klient