database->escape(ip2long($request_ip)); $timestamp_escaped = $this->database->escape($timestamp); $query = ' select count(*) as number_requests_since from api_log where request_ip = ' . $request_ip_escaped . ' and request_timestamp >= from_unixtime(' . $timestamp_escaped . ') '; // Getting the number of requests since a certain date is considered // overhead since it's only used for rate limiting. See "Important" note in // documentation. $result = $this->database->query($query); $row = $result->fetch_assoc(); return $row['number_requests_since']; } }