293 |
293 |
$this->stmt->bindParam(':tag_id', $_POST['tag_id'], PDO::PARAM_INT);
|
294 |
294 |
}
|
295 |
295 |
$this->stmt->execute();
|
296 |
|
}}
|
|
296 |
}
|
|
297 |
|
|
298 |
function insert(){
|
|
299 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
300 |
|
|
301 |
$query = "SELECT MAX(id) FROM dd_wordform;";
|
|
302 |
$this->stmt = $this->pdo->prepare($query);
|
|
303 |
$this->stmt->execute();
|
|
304 |
$result = $this->stmt->fetchAll();
|
|
305 |
$result[0]["max"]+=1;
|
|
306 |
|
|
307 |
|
|
308 |
$query = "INSERT INTO dd_wordform ( id, ";
|
|
309 |
$values = "VALUES (" . $result[0]["max"] . ", ";
|
|
310 |
|
|
311 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") {
|
|
312 |
$query .= " context, ";
|
|
313 |
$values .= " :context, ";
|
|
314 |
}
|
|
315 |
$query .= " date, ";
|
|
316 |
$values .= " CURRENT_DATE, ";
|
|
317 |
|
|
318 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") {
|
|
319 |
$query .= " description, ";
|
|
320 |
$values .= " :description, ";
|
|
321 |
}
|
|
322 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") {
|
|
323 |
$query .= " description2, ";
|
|
324 |
$values .= " :description2, ";
|
|
325 |
}
|
|
326 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") {
|
|
327 |
$query .= " description3, ";
|
|
328 |
$values .= " :description3, ";
|
|
329 |
}
|
|
330 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") {
|
|
331 |
$query .= " ending, ";
|
|
332 |
$values .= " :ending, ";
|
|
333 |
}
|
|
334 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") {
|
|
335 |
$query .= " finished, ";
|
|
336 |
$values .= " :finished, ";
|
|
337 |
}
|
|
338 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") {
|
|
339 |
$query .= " namedentity, ";
|
|
340 |
$values .= " :namedentity, ";
|
|
341 |
}
|
|
342 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") {
|
|
343 |
$query .= " position1, ";
|
|
344 |
$values .= " :position1, ";
|
|
345 |
}
|
|
346 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") {
|
|
347 |
$query .= " position2, ";
|
|
348 |
$values .= " :position2, ";
|
|
349 |
}
|
|
350 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") {
|
|
351 |
$query .= " positiondetail, ";
|
|
352 |
$values .= " :positiondetail, ";
|
|
353 |
}
|
|
354 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") {
|
|
355 |
$query .= " prefix, ";
|
|
356 |
$values .= " :prefix, ";
|
|
357 |
}
|
|
358 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") {
|
|
359 |
$query .= " suffix, ";
|
|
360 |
$values .= " :suffix, ";
|
|
361 |
}
|
|
362 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") {
|
|
363 |
$query .= " word, ";
|
|
364 |
$values .= " :word, ";
|
|
365 |
}
|
|
366 |
if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
|
|
367 |
$query .= " lemma_id, ";
|
|
368 |
$values .= " :lemma_id, ";
|
|
369 |
}
|
|
370 |
if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
|
|
371 |
$query .= " tag_id ) ";
|
|
372 |
$values .= " :tag_id ); ";
|
|
373 |
}
|
|
374 |
|
|
375 |
$query .= $values;
|
|
376 |
$this->stmt = $this->pdo->prepare($query);
|
|
377 |
|
|
378 |
if (array_key_exists("context", $_POST) && $_POST['context'] != "") {
|
|
379 |
$this->stmt->bindParam(':context', $_POST['context'], PDO::PARAM_STR);
|
|
380 |
}
|
|
381 |
if (array_key_exists("description", $_POST) && $_POST['description'] != "") {
|
|
382 |
$this->stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR);
|
|
383 |
}
|
|
384 |
if (array_key_exists("description2", $_POST) && $_POST['description2'] != "") {
|
|
385 |
$this->stmt->bindParam(':description2', $_POST['description2'], PDO::PARAM_STR);
|
|
386 |
}
|
|
387 |
if (array_key_exists("description3", $_POST) && $_POST['description3'] != "") {
|
|
388 |
$this->stmt->bindParam(':description3', $_POST['description3'], PDO::PARAM_STR);
|
|
389 |
}
|
|
390 |
if (array_key_exists("ending", $_POST) && $_POST['ending'] != "") {
|
|
391 |
$this->stmt->bindParam(':ending', $_POST['ending'], PDO::PARAM_STR);
|
|
392 |
}
|
|
393 |
if (array_key_exists("finished", $_POST) && $_POST['finished'] != "") {
|
|
394 |
$this->stmt->bindParam(':finished', $_POST['finished']);
|
|
395 |
}
|
|
396 |
if (array_key_exists("namedentity", $_POST) && $_POST['namedentity'] != "") {
|
|
397 |
$this->stmt->bindParam(':namedentity', $_POST['namedentity'], PDO::PARAM_INT);
|
|
398 |
}
|
|
399 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") {
|
|
400 |
$this->stmt->bindParam(':position1', $_POST['position1'], PDO::PARAM_STR);
|
|
401 |
}
|
|
402 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") {
|
|
403 |
$this->stmt->bindParam(':position2', $_POST['position2'], PDO::PARAM_STR);
|
|
404 |
}
|
|
405 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") {
|
|
406 |
$this->stmt->bindParam(':positiondetail', $_POST['positiondetail'], PDO::PARAM_STR);
|
|
407 |
}
|
|
408 |
if (array_key_exists("prefix", $_POST) && $_POST['prefix'] != "") {
|
|
409 |
$this->stmt->bindParam(':prefix', $_POST['prefix'], PDO::PARAM_STR);
|
|
410 |
}
|
|
411 |
if (array_key_exists("suffix", $_POST) && $_POST['suffix'] != "") {
|
|
412 |
$this->stmt->bindParam(':suffix', $_POST['suffix'], PDO::PARAM_STR);
|
|
413 |
}
|
|
414 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") {
|
|
415 |
$this->stmt->bindParam(':word', $_POST['word'], PDO::PARAM_STR);
|
|
416 |
}
|
|
417 |
if (array_key_exists("lemma_id", $_POST) && $_POST['lemma_id'] != "") {
|
|
418 |
$this->stmt->bindParam(':lemma_id', $_POST['lemma_id'], PDO::PARAM_INT);
|
|
419 |
}
|
|
420 |
if (array_key_exists("tag_id", $_POST) && $_POST['tag_id'] != "") {
|
|
421 |
$this->stmt->bindParam(':tag_id', $_POST['tag_id'], PDO::PARAM_INT);
|
|
422 |
}
|
|
423 |
|
|
424 |
$this->stmt->execute();
|
|
425 |
|
|
426 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
427 |
|
|
428 |
$query = "SELECT MAX(id) FROM dd_lemma;";
|
|
429 |
$this->stmt = $this->pdo->prepare($query);
|
|
430 |
$this->stmt->execute();
|
|
431 |
$result = $this->stmt->fetchAll();
|
|
432 |
$result[0]["max"]+=1;
|
|
433 |
|
|
434 |
$query = "INSERT INTO dd_lemma ( id, ";
|
|
435 |
$values = "VALUES (" . $result[0]["max"] . ", ";
|
|
436 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
|
|
437 |
$query .= " lemma, ";
|
|
438 |
$values .= " :lemma, ";
|
|
439 |
}
|
|
440 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") {
|
|
441 |
$query .= " pos ) ";
|
|
442 |
$values .= " :pos ); ";
|
|
443 |
}
|
|
444 |
|
|
445 |
$query .= $values;
|
|
446 |
$this->stmt = $this->pdo->prepare($query);
|
|
447 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
|
|
448 |
$this->stmt->bindParam(':lemma', $_POST['lemma'], PDO::PARAM_STR);
|
|
449 |
}
|
|
450 |
if (array_key_exists("pos", $_POST) && $_POST['pos'] != "") {
|
|
451 |
$this->stmt->bindParam(':pos', $_POST['pos'], PDO::PARAM_INT);
|
|
452 |
}
|
|
453 |
$this->stmt->execute();
|
|
454 |
|
|
455 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
456 |
|
|
457 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
|
|
458 |
$query = "SELECT * FROM dd_manuscript WHERE ";
|
|
459 |
$query .= " wordform_id = :wordform_id ;";
|
|
460 |
}
|
|
461 |
|
|
462 |
$this->stmt = $this->pdo->prepare($query);
|
|
463 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
|
|
464 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT);
|
|
465 |
}
|
|
466 |
$this->stmt->execute();
|
|
467 |
$result = $this->stmt->fetchAll();
|
|
468 |
|
|
469 |
$to_insert = [];
|
|
470 |
$contained = [];
|
|
471 |
$found = false;
|
|
472 |
|
|
473 |
foreach ($result as $res) {
|
|
474 |
$integerIDs = array_map('intval', explode(',', $_POST['manuscript']));
|
|
475 |
foreach ($integerIDs as $new_value){
|
|
476 |
if($new_value == $res['manuscript']){
|
|
477 |
$found = true;
|
|
478 |
array_push($contained, $new_value);
|
|
479 |
}
|
|
480 |
}
|
|
481 |
if($found == false){
|
|
482 |
array_push($to_delete, $res);
|
|
483 |
}
|
|
484 |
$found = false;
|
|
485 |
}
|
|
486 |
$to_insert = array_diff($integerIDs, $contained);
|
|
487 |
foreach ($to_insert as $id_to_insert){
|
|
488 |
$query = "INSERT INTO dd_manuscript VALUES ( ";
|
|
489 |
$query .= " :wordform_id , ";
|
|
490 |
$query .= " " . $id_to_insert . " ); ";
|
|
491 |
|
|
492 |
$this->stmt = $this->pdo->prepare($query);
|
|
493 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") {
|
|
494 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT);
|
|
495 |
}
|
|
496 |
$this->stmt->execute();
|
|
497 |
}
|
|
498 |
|
|
499 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
500 |
$query = "SELECT MAX(id) FROM dd_tag;";
|
|
501 |
$this->stmt = $this->pdo->prepare($query);
|
|
502 |
$this->stmt->execute();
|
|
503 |
$result = $this->stmt->fetchAll();
|
|
504 |
$result[0]["max"]+=1;
|
|
505 |
|
|
506 |
|
|
507 |
$query = "INSERT INTO dd_tag (id, ";
|
|
508 |
$values = "VALUES (" . $result[0]["max"] . ", ";
|
|
509 |
|
|
510 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
|
|
511 |
$query .= " tag ) ";
|
|
512 |
$values .= " :tag ); ";
|
|
513 |
}
|
|
514 |
|
|
515 |
$query .= $values;
|
|
516 |
$this->stmt = $this->pdo->prepare($query);
|
|
517 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
|
|
518 |
$this->stmt->bindParam(':tag', $_POST['tag'], PDO::PARAM_STR);
|
|
519 |
}
|
|
520 |
$this->stmt->execute();
|
|
521 |
|
|
522 |
|
|
523 |
}
|
|
524 |
|
|
525 |
}
|
297 |
526 |
|
298 |
527 |
// (D) DATABASE SETTINGS - CHANGE TO YOUR OWN!
|
299 |
528 |
define('DB_HOST', 'localhost');
|
300 |
529 |
define('DB_NAME', 'dalim2');
|
301 |
530 |
define('DB_CHARSET', 'utf8');
|
302 |
531 |
define('DB_USER', 'postgres');
|
303 |
|
define('DB_PASSWORD', 'a');
|
|
532 |
define('DB_PASSWORD', 'MVcesko98');
|
Feature #8524 Metoda pro tvorbu nových záznamů