@@ 531-569 (lines=39) @@ | ||
528 | * @return bool If the insert was successful |
|
529 | * @throws \Longman\TelegramBot\Exception\TelegramException |
|
530 | */ |
|
531 | public static function insertInlineQueryRequest(InlineQuery $inline_query) |
|
532 | { |
|
533 | if (!self::isDbConnected()) { |
|
534 | return false; |
|
535 | } |
|
536 | ||
537 | try { |
|
538 | $sth = self::$pdo->prepare(' |
|
539 | INSERT IGNORE INTO `' . TB_INLINE_QUERY . '` |
|
540 | (`id`, `user_id`, `location`, `query`, `offset`, `created_at`) |
|
541 | VALUES |
|
542 | (:inline_query_id, :user_id, :location, :query, :param_offset, :created_at) |
|
543 | '); |
|
544 | ||
545 | $date = self::getTimestamp(); |
|
546 | $inline_query_id = $inline_query->getId(); |
|
547 | $from = $inline_query->getFrom(); |
|
548 | $user_id = null; |
|
549 | if ($from instanceof User) { |
|
550 | $user_id = $from->getId(); |
|
551 | self::insertUser($from, $date); |
|
552 | } |
|
553 | ||
554 | $location = $inline_query->getLocation(); |
|
555 | $query = $inline_query->getQuery(); |
|
556 | $offset = $inline_query->getOffset(); |
|
557 | ||
558 | $sth->bindParam(':inline_query_id', $inline_query_id, PDO::PARAM_INT); |
|
559 | $sth->bindParam(':user_id', $user_id, PDO::PARAM_INT); |
|
560 | $sth->bindParam(':location', $location, PDO::PARAM_STR); |
|
561 | $sth->bindParam(':query', $query, PDO::PARAM_STR); |
|
562 | $sth->bindParam(':param_offset', $offset, PDO::PARAM_STR); |
|
563 | $sth->bindParam(':created_at', $date, PDO::PARAM_STR); |
|
564 | ||
565 | return $sth->execute(); |
|
566 | } catch (PDOException $e) { |
|
567 | throw new TelegramException($e->getMessage()); |
|
568 | } |
|
569 | } |
|
570 | ||
571 | /** |
|
572 | * Insert chosen inline result request into database |
|
@@ 579-617 (lines=39) @@ | ||
576 | * @return bool If the insert was successful |
|
577 | * @throws \Longman\TelegramBot\Exception\TelegramException |
|
578 | */ |
|
579 | public static function insertChosenInlineResultRequest(ChosenInlineResult $chosen_inline_result) |
|
580 | { |
|
581 | if (!self::isDbConnected()) { |
|
582 | return false; |
|
583 | } |
|
584 | ||
585 | try { |
|
586 | $sth = self::$pdo->prepare(' |
|
587 | INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '` |
|
588 | (`result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`) |
|
589 | VALUES |
|
590 | (:result_id, :user_id, :location, :inline_message_id, :query, :created_at) |
|
591 | '); |
|
592 | ||
593 | $date = self::getTimestamp(); |
|
594 | $result_id = $chosen_inline_result->getResultId(); |
|
595 | $from = $chosen_inline_result->getFrom(); |
|
596 | $user_id = null; |
|
597 | if ($from instanceof User) { |
|
598 | $user_id = $from->getId(); |
|
599 | self::insertUser($from, $date); |
|
600 | } |
|
601 | ||
602 | $location = $chosen_inline_result->getLocation(); |
|
603 | $inline_message_id = $chosen_inline_result->getInlineMessageId(); |
|
604 | $query = $chosen_inline_result->getQuery(); |
|
605 | ||
606 | $sth->bindParam(':result_id', $result_id, PDO::PARAM_STR); |
|
607 | $sth->bindParam(':user_id', $user_id, PDO::PARAM_INT); |
|
608 | $sth->bindParam(':location', $location, PDO::PARAM_INT); |
|
609 | $sth->bindParam(':inline_message_id', $inline_message_id, PDO::PARAM_STR); |
|
610 | $sth->bindParam(':query', $query, PDO::PARAM_STR); |
|
611 | $sth->bindParam(':created_at', $date, PDO::PARAM_STR); |
|
612 | ||
613 | return $sth->execute(); |
|
614 | } catch (PDOException $e) { |
|
615 | throw new TelegramException($e->getMessage()); |
|
616 | } |
|
617 | } |
|
618 | ||
619 | /** |
|
620 | * Insert callback query request into database |