Longman\TelegramBot\DB::insertChosenInlineResultRequest PHP Method

insertChosenInlineResultRequest() public static method

Insert chosen inline result request into database
public static insertChosenInlineResultRequest ( ChosenInlineResult $chosen_inline_result ) : boolean
$chosen_inline_result Longman\TelegramBot\Entities\ChosenInlineResult
return boolean If the insert was successful
    public static function insertChosenInlineResultRequest(ChosenInlineResult $chosen_inline_result)
    {
        if (!self::isDbConnected()) {
            return false;
        }
        try {
            $sth = self::$pdo->prepare('
                INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '`
                (`result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`)
                VALUES
                (:result_id, :user_id, :location, :inline_message_id, :query, :created_at)
            ');
            $date = self::getTimestamp();
            $result_id = $chosen_inline_result->getResultId();
            $from = $chosen_inline_result->getFrom();
            $user_id = null;
            if ($from instanceof User) {
                $user_id = $from->getId();
                self::insertUser($from, $date);
            }
            $location = $chosen_inline_result->getLocation();
            $inline_message_id = $chosen_inline_result->getInlineMessageId();
            $query = $chosen_inline_result->getQuery();
            $sth->bindParam(':result_id', $result_id, PDO::PARAM_STR);
            $sth->bindParam(':user_id', $user_id, PDO::PARAM_INT);
            $sth->bindParam(':location', $location, PDO::PARAM_INT);
            $sth->bindParam(':inline_message_id', $inline_message_id, PDO::PARAM_STR);
            $sth->bindParam(':query', $query, PDO::PARAM_STR);
            $sth->bindParam(':created_at', $date, PDO::PARAM_STR);
            return $sth->execute();
        } catch (PDOException $e) {
            throw new TelegramException($e->getMessage());
        }
    }