@@ 560-598 (lines=39) @@ | ||
557 | * @return bool If the insert was successful |
|
558 | * @throws \Longman\TelegramBot\Exception\TelegramException |
|
559 | */ |
|
560 | public static function insertInlineQueryRequest(InlineQuery $inline_query) |
|
561 | { |
|
562 | if (!self::isDbConnected()) { |
|
563 | return false; |
|
564 | } |
|
565 | ||
566 | try { |
|
567 | $sth = self::$pdo->prepare(' |
|
568 | INSERT IGNORE INTO `' . TB_INLINE_QUERY . '` |
|
569 | (`id`, `user_id`, `location`, `query`, `offset`, `created_at`) |
|
570 | VALUES |
|
571 | (:inline_query_id, :user_id, :location, :query, :param_offset, :created_at) |
|
572 | '); |
|
573 | ||
574 | $date = self::getTimestamp(); |
|
575 | $inline_query_id = $inline_query->getId(); |
|
576 | $from = $inline_query->getFrom(); |
|
577 | $user_id = null; |
|
578 | if ($from instanceof User) { |
|
579 | $user_id = $from->getId(); |
|
580 | self::insertUser($from, $date); |
|
581 | } |
|
582 | ||
583 | $location = $inline_query->getLocation(); |
|
584 | $query = $inline_query->getQuery(); |
|
585 | $offset = $inline_query->getOffset(); |
|
586 | ||
587 | $sth->bindParam(':inline_query_id', $inline_query_id, PDO::PARAM_INT); |
|
588 | $sth->bindParam(':user_id', $user_id, PDO::PARAM_INT); |
|
589 | $sth->bindParam(':location', $location, PDO::PARAM_STR); |
|
590 | $sth->bindParam(':query', $query, PDO::PARAM_STR); |
|
591 | $sth->bindParam(':param_offset', $offset, PDO::PARAM_STR); |
|
592 | $sth->bindParam(':created_at', $date, PDO::PARAM_STR); |
|
593 | ||
594 | return $sth->execute(); |
|
595 | } catch (PDOException $e) { |
|
596 | throw new TelegramException($e->getMessage()); |
|
597 | } |
|
598 | } |
|
599 | ||
600 | /** |
|
601 | * Insert chosen inline result request into database |
|
@@ 608-646 (lines=39) @@ | ||
605 | * @return bool If the insert was successful |
|
606 | * @throws \Longman\TelegramBot\Exception\TelegramException |
|
607 | */ |
|
608 | public static function insertChosenInlineResultRequest(ChosenInlineResult $chosen_inline_result) |
|
609 | { |
|
610 | if (!self::isDbConnected()) { |
|
611 | return false; |
|
612 | } |
|
613 | ||
614 | try { |
|
615 | $sth = self::$pdo->prepare(' |
|
616 | INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '` |
|
617 | (`result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`) |
|
618 | VALUES |
|
619 | (:result_id, :user_id, :location, :inline_message_id, :query, :created_at) |
|
620 | '); |
|
621 | ||
622 | $date = self::getTimestamp(); |
|
623 | $result_id = $chosen_inline_result->getResultId(); |
|
624 | $from = $chosen_inline_result->getFrom(); |
|
625 | $user_id = null; |
|
626 | if ($from instanceof User) { |
|
627 | $user_id = $from->getId(); |
|
628 | self::insertUser($from, $date); |
|
629 | } |
|
630 | ||
631 | $location = $chosen_inline_result->getLocation(); |
|
632 | $inline_message_id = $chosen_inline_result->getInlineMessageId(); |
|
633 | $query = $chosen_inline_result->getQuery(); |
|
634 | ||
635 | $sth->bindParam(':result_id', $result_id, PDO::PARAM_STR); |
|
636 | $sth->bindParam(':user_id', $user_id, PDO::PARAM_INT); |
|
637 | $sth->bindParam(':location', $location, PDO::PARAM_INT); |
|
638 | $sth->bindParam(':inline_message_id', $inline_message_id, PDO::PARAM_STR); |
|
639 | $sth->bindParam(':query', $query, PDO::PARAM_STR); |
|
640 | $sth->bindParam(':created_at', $date, PDO::PARAM_STR); |
|
641 | ||
642 | return $sth->execute(); |
|
643 | } catch (PDOException $e) { |
|
644 | throw new TelegramException($e->getMessage()); |
|
645 | } |
|
646 | } |
|
647 | ||
648 | /** |
|
649 | * Insert callback query request into database |