如何在一个pdoQuery中获取两个相关表和一个不相关的多计数?

时间:2017-03-12 20:55:02

标签: php mysql pdo wrapper

我在我的数据库中做了很多不必要的查询,导致第一个字节的时间变慢。我正在使用PHP PDO Class Wrapper Version 1.2(Beta)。

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

我设法使用LEFT JOIN从相关表中获取计数,但我还需要一个来自不相关表的结果,我不知道该怎么做。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我设法以下列方式制作

let refDb = FIRDatabase.database().reference().child("game-stats").child(key).queryOrdered(byChild: "percent").queryLimited(toLast: 5)

感谢chris85的帮助