@@ 637-671 (lines=35) @@ | ||
634 | * @return bool If the insert was successful |
|
635 | * @throws TelegramException |
|
636 | */ |
|
637 | public static function insertInlineQueryRequest(InlineQuery $inline_query) |
|
638 | { |
|
639 | if (!self::isDbConnected()) { |
|
640 | return false; |
|
641 | } |
|
642 | ||
643 | try { |
|
644 | $sth = self::$pdo->prepare(' |
|
645 | INSERT IGNORE INTO `' . TB_INLINE_QUERY . '` |
|
646 | (`id`, `user_id`, `location`, `query`, `offset`, `created_at`) |
|
647 | VALUES |
|
648 | (:id, :user_id, :location, :query, :offset, :created_at) |
|
649 | '); |
|
650 | ||
651 | $date = self::getTimestamp(); |
|
652 | $user_id = null; |
|
653 | ||
654 | $user = $inline_query->getFrom(); |
|
655 | if ($user instanceof User) { |
|
656 | $user_id = $user->getId(); |
|
657 | self::insertUser($user, $date); |
|
658 | } |
|
659 | ||
660 | $sth->bindValue(':id', $inline_query->getId()); |
|
661 | $sth->bindValue(':user_id', $user_id); |
|
662 | $sth->bindValue(':location', $inline_query->getLocation()); |
|
663 | $sth->bindValue(':query', $inline_query->getQuery()); |
|
664 | $sth->bindValue(':offset', $inline_query->getOffset()); |
|
665 | $sth->bindValue(':created_at', $date); |
|
666 | ||
667 | return $sth->execute(); |
|
668 | } catch (PDOException $e) { |
|
669 | throw new TelegramException($e->getMessage()); |
|
670 | } |
|
671 | } |
|
672 | ||
673 | /** |
|
674 | * Insert chosen inline result request into database |
|
@@ 681-715 (lines=35) @@ | ||
678 | * @return bool If the insert was successful |
|
679 | * @throws TelegramException |
|
680 | */ |
|
681 | public static function insertChosenInlineResultRequest(ChosenInlineResult $chosen_inline_result) |
|
682 | { |
|
683 | if (!self::isDbConnected()) { |
|
684 | return false; |
|
685 | } |
|
686 | ||
687 | try { |
|
688 | $sth = self::$pdo->prepare(' |
|
689 | INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '` |
|
690 | (`result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`) |
|
691 | VALUES |
|
692 | (:result_id, :user_id, :location, :inline_message_id, :query, :created_at) |
|
693 | '); |
|
694 | ||
695 | $date = self::getTimestamp(); |
|
696 | $user_id = null; |
|
697 | ||
698 | $user = $chosen_inline_result->getFrom(); |
|
699 | if ($user instanceof User) { |
|
700 | $user_id = $user->getId(); |
|
701 | self::insertUser($user, $date); |
|
702 | } |
|
703 | ||
704 | $sth->bindValue(':result_id', $chosen_inline_result->getResultId()); |
|
705 | $sth->bindValue(':user_id', $user_id); |
|
706 | $sth->bindValue(':location', $chosen_inline_result->getLocation()); |
|
707 | $sth->bindValue(':inline_message_id', $chosen_inline_result->getInlineMessageId()); |
|
708 | $sth->bindValue(':query', $chosen_inline_result->getQuery()); |
|
709 | $sth->bindValue(':created_at', $date); |
|
710 | ||
711 | return $sth->execute(); |
|
712 | } catch (PDOException $e) { |
|
713 | throw new TelegramException($e->getMessage()); |
|
714 | } |
|
715 | } |
|
716 | ||
717 | /** |
|
718 | * Insert callback query request into database |