/** * Insert inline query request into database * * @param Entities\InlineQuery &$inline_query * * @return bool If the insert was successful * @throws TelegramException */ public static function insertInlineQueryRequest(InlineQuery &$inline_query) { if (!self::isDbConnected()) { return false; } try { $mysql_query = 'INSERT IGNORE INTO `' . TB_INLINE_QUERY . '` ( `id`, `user_id`, `location`, `query`, `offset`, `created_at` ) VALUES ( :inline_query_id, :user_id, :location, :query, :param_offset, :created_at )'; $sth_insert_inline_query = self::$pdo->prepare($mysql_query); $date = self::getTimestamp(time()); $inline_query_id = $inline_query->getId(); $from = $inline_query->getFrom(); $user_id = null; if (is_object($from)) { $user_id = $from->getId(); self::insertUser($from, $date); } $location = $inline_query->getLocation(); $query = $inline_query->getQuery(); $offset = $inline_query->getOffset(); $sth_insert_inline_query->bindParam(':inline_query_id', $inline_query_id, \PDO::PARAM_INT); $sth_insert_inline_query->bindParam(':user_id', $user_id, \PDO::PARAM_INT); $sth_insert_inline_query->bindParam(':location', $location, \PDO::PARAM_STR); $sth_insert_inline_query->bindParam(':query', $query, \PDO::PARAM_STR); $sth_insert_inline_query->bindParam(':param_offset', $offset, \PDO::PARAM_STR); $sth_insert_inline_query->bindParam(':created_at', $date, \PDO::PARAM_STR); return $sth_insert_inline_query->execute(); } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } }