Browse Source

Move pdo connection to app.php (#5139)

* Move pdo connection to app.php

* Delete persistent db connection
if all the workers are reusing the same connection,  may be detrimental

* Change in php-ngx-psgql.dockerfile
Joan Miquel 5 years ago
parent
commit
3a2e01f94c

+ 4 - 0
frameworks/PHP/php-ngx/app.php

@@ -1,5 +1,9 @@
 <?php
 
+global $pdo;
+$pdo = new PDO("mysql:host=tfb-database;dbname=hello_world", "benchmarkdbuser", "benchmarkdbpass");
+
+
 function db()
 {
     global $pdo;

+ 0 - 5
frameworks/PHP/php-ngx/deploy/nginx.conf

@@ -25,11 +25,6 @@ http {
     php_ini_path /deploy/conf/php.ini;
 
     init_worker_by_php '
-        global $pdo;
-        $pdo = new PDO("mysql:host=tfb-database;dbname=hello_world", "benchmarkdbuser", "benchmarkdbpass", [
-                    PDO::ATTR_PERSISTENT => true
-                ]);
-        
         require "app.php";
     ';
 

+ 1 - 1
frameworks/PHP/php-ngx/php-ngx-pgsql.dockerfile

@@ -26,7 +26,7 @@ RUN wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
             --add-module=/ngx_php7 > /dev/null && \
     make > /dev/null && make install > /dev/null
 
-RUN sed -i "s|mysql:|pgsql:|g" /deploy/nginx.conf
+RUN sed -i "s|mysql:|pgsql:|g" /app.php
 
 CMD /nginx/sbin/nginx -c /deploy/nginx.conf