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