@@ 595-633 (lines=39) @@ | ||
592 | * @return bool If the insert was successful |
|
593 | * @throws \Longman\TelegramBot\Exception\TelegramException |
|
594 | */ |
|
595 | public static function insertInlineQueryRequest(InlineQuery $inline_query) |
|
596 | { |
|
597 | if (!self::isDbConnected()) { |
|
598 | return false; |
|
599 | } |
|
600 | ||
601 | try { |
|
602 | $sth = self::$pdo->prepare(' |
|
603 | INSERT IGNORE INTO `' . TB_INLINE_QUERY . '` |
|
604 | (`id`, `user_id`, `location`, `query`, `offset`, `created_at`) |
|
605 | VALUES |
|
606 | (:inline_query_id, :user_id, :location, :query, :param_offset, :created_at) |
|
607 | '); |
|
608 | ||
609 | $date = self::getTimestamp(); |
|
610 | $inline_query_id = $inline_query->getId(); |
|
611 | $from = $inline_query->getFrom(); |
|
612 | $user_id = null; |
|
613 | if ($from instanceof User) { |
|
614 | $user_id = $from->getId(); |
|
615 | self::insertUser($from, $date); |
|
616 | } |
|
617 | ||
618 | $location = $inline_query->getLocation(); |
|
619 | $query = $inline_query->getQuery(); |
|
620 | $offset = $inline_query->getOffset(); |
|
621 | ||
622 | $sth->bindParam(':inline_query_id', $inline_query_id, PDO::PARAM_STR); |
|
623 | $sth->bindParam(':user_id', $user_id, PDO::PARAM_STR); |
|
624 | $sth->bindParam(':location', $location, PDO::PARAM_STR); |
|
625 | $sth->bindParam(':query', $query, PDO::PARAM_STR); |
|
626 | $sth->bindParam(':param_offset', $offset, PDO::PARAM_STR); |
|
627 | $sth->bindParam(':created_at', $date, PDO::PARAM_STR); |
|
628 | ||
629 | return $sth->execute(); |
|
630 | } catch (PDOException $e) { |
|
631 | throw new TelegramException($e->getMessage()); |
|
632 | } |
|
633 | } |
|
634 | ||
635 | /** |
|
636 | * Insert chosen inline result request into database |
|
@@ 643-681 (lines=39) @@ | ||
640 | * @return bool If the insert was successful |
|
641 | * @throws \Longman\TelegramBot\Exception\TelegramException |
|
642 | */ |
|
643 | public static function insertChosenInlineResultRequest(ChosenInlineResult $chosen_inline_result) |
|
644 | { |
|
645 | if (!self::isDbConnected()) { |
|
646 | return false; |
|
647 | } |
|
648 | ||
649 | try { |
|
650 | $sth = self::$pdo->prepare(' |
|
651 | INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '` |
|
652 | (`result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`) |
|
653 | VALUES |
|
654 | (:result_id, :user_id, :location, :inline_message_id, :query, :created_at) |
|
655 | '); |
|
656 | ||
657 | $date = self::getTimestamp(); |
|
658 | $result_id = $chosen_inline_result->getResultId(); |
|
659 | $from = $chosen_inline_result->getFrom(); |
|
660 | $user_id = null; |
|
661 | if ($from instanceof User) { |
|
662 | $user_id = $from->getId(); |
|
663 | self::insertUser($from, $date); |
|
664 | } |
|
665 | ||
666 | $location = $chosen_inline_result->getLocation(); |
|
667 | $inline_message_id = $chosen_inline_result->getInlineMessageId(); |
|
668 | $query = $chosen_inline_result->getQuery(); |
|
669 | ||
670 | $sth->bindParam(':result_id', $result_id, PDO::PARAM_STR); |
|
671 | $sth->bindParam(':user_id', $user_id, PDO::PARAM_STR); |
|
672 | $sth->bindParam(':location', $location, PDO::PARAM_STR); |
|
673 | $sth->bindParam(':inline_message_id', $inline_message_id, PDO::PARAM_STR); |
|
674 | $sth->bindParam(':query', $query, PDO::PARAM_STR); |
|
675 | $sth->bindParam(':created_at', $date, PDO::PARAM_STR); |
|
676 | ||
677 | return $sth->execute(); |
|
678 | } catch (PDOException $e) { |
|
679 | throw new TelegramException($e->getMessage()); |
|
680 | } |
|
681 | } |
|
682 | ||
683 | /** |
|
684 | * Insert callback query request into database |