@@ 617-651 (lines=35) @@ | ||
614 | * @return bool If the insert was successful |
|
615 | * @throws TelegramException |
|
616 | */ |
|
617 | public static function insertInlineQueryRequest(InlineQuery $inline_query) |
|
618 | { |
|
619 | if (!self::isDbConnected()) { |
|
620 | return false; |
|
621 | } |
|
622 | ||
623 | try { |
|
624 | $sth = self::$pdo->prepare(' |
|
625 | INSERT IGNORE INTO `' . TB_INLINE_QUERY . '` |
|
626 | (`id`, `user_id`, `location`, `query`, `offset`, `created_at`) |
|
627 | VALUES |
|
628 | (:id, :user_id, :location, :query, :offset, :created_at) |
|
629 | '); |
|
630 | ||
631 | $date = self::getTimestamp(); |
|
632 | $user_id = null; |
|
633 | ||
634 | $user = $inline_query->getFrom(); |
|
635 | if ($user instanceof User) { |
|
636 | $user_id = $user->getId(); |
|
637 | self::insertUser($user, $date); |
|
638 | } |
|
639 | ||
640 | $sth->bindValue(':id', $inline_query->getId()); |
|
641 | $sth->bindValue(':user_id', $user_id); |
|
642 | $sth->bindValue(':location', $inline_query->getLocation()); |
|
643 | $sth->bindValue(':query', $inline_query->getQuery()); |
|
644 | $sth->bindValue(':offset', $inline_query->getOffset()); |
|
645 | $sth->bindValue(':created_at', $date); |
|
646 | ||
647 | return $sth->execute(); |
|
648 | } catch (PDOException $e) { |
|
649 | throw new TelegramException($e->getMessage()); |
|
650 | } |
|
651 | } |
|
652 | ||
653 | /** |
|
654 | * Insert chosen inline result request into database |
|
@@ 661-695 (lines=35) @@ | ||
658 | * @return bool If the insert was successful |
|
659 | * @throws TelegramException |
|
660 | */ |
|
661 | public static function insertChosenInlineResultRequest(ChosenInlineResult $chosen_inline_result) |
|
662 | { |
|
663 | if (!self::isDbConnected()) { |
|
664 | return false; |
|
665 | } |
|
666 | ||
667 | try { |
|
668 | $sth = self::$pdo->prepare(' |
|
669 | INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '` |
|
670 | (`result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`) |
|
671 | VALUES |
|
672 | (:result_id, :user_id, :location, :inline_message_id, :query, :created_at) |
|
673 | '); |
|
674 | ||
675 | $date = self::getTimestamp(); |
|
676 | $user_id = null; |
|
677 | ||
678 | $user = $chosen_inline_result->getFrom(); |
|
679 | if ($user instanceof User) { |
|
680 | $user_id = $user->getId(); |
|
681 | self::insertUser($user, $date); |
|
682 | } |
|
683 | ||
684 | $sth->bindValue(':result_id', $chosen_inline_result->getResultId()); |
|
685 | $sth->bindValue(':user_id', $user_id); |
|
686 | $sth->bindValue(':location', $chosen_inline_result->getLocation()); |
|
687 | $sth->bindValue(':inline_message_id', $chosen_inline_result->getInlineMessageId()); |
|
688 | $sth->bindValue(':query', $chosen_inline_result->getQuery()); |
|
689 | $sth->bindValue(':created_at', $date); |
|
690 | ||
691 | return $sth->execute(); |
|
692 | } catch (PDOException $e) { |
|
693 | throw new TelegramException($e->getMessage()); |
|
694 | } |
|
695 | } |
|
696 | ||
697 | /** |
|
698 | * Insert callback query request into database |