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