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