Browse Source

Use persistent db connections (#3658)

* Use persistent db connections

* Persistent db connection for hhvm

* Pesistent db connection in Phalcon, zend and zend1

* Fat-free persistent db connection
Joan Miquel 7 years ago
parent
commit
2a3b3a6a41

+ 1 - 1
frameworks/PHP/cakephp/app/Config/database.php

@@ -61,7 +61,7 @@ class DATABASE_CONFIG {
 
 	public $default = array(
 		'datasource' => 'Database/Mysql',
-		'persistent' => false,
+		'persistent' => true,
 		'host' => 'tfb-database',
 		'login' => 'benchmarkdbuser',
 		'password' => 'benchmarkdbpass',

+ 1 - 1
frameworks/PHP/fat-free/index.php

@@ -18,7 +18,7 @@ $f3->set('ONERROR',function($f3){
     echo $f3->get('ERROR.code').': '.$f3->get('ERROR.text')."\n".$f3->get('ERROR.trace');
 });
 
-$f3->set('DBS',array('mysql:host=tfb-database;port=3306;dbname=hello_world','benchmarkdbuser','benchmarkdbpass'));
+$f3->set('DBS',array('mysql:host=tfb-database;port=3306;dbname=hello_world','benchmarkdbuser','benchmarkdbpass',[PDO::ATTR_PERSISTENT => true]));
 // http: //www.techempower.com/benchmarks/#section=code
 
 // JSON test

+ 1 - 1
frameworks/PHP/hhvm/once.php.inc

@@ -9,7 +9,7 @@ class Benchmark {
             'mysql:host=tfb-database;dbname=hello_world;charset=utf8',
             'benchmarkdbuser',
             'benchmarkdbpass',
-            array(PDO::ATTR_PERSISTENT => false));
+            array(PDO::ATTR_PERSISTENT => true));
     }
 
     public function bench_json()

+ 1 - 1
frameworks/PHP/kohana/application/config/database.php

@@ -17,7 +17,7 @@ return array
 	    'dsn'        => 'mysql:host=tfb-database;dbname=hello_world',
             'username'   => 'benchmarkdbuser',
             'password'   => 'benchmarkdbpass',
-            'persistent' => FALSE,
+            'persistent' => true,
         ),
         'table_prefix' => '',
         'charset'      => 'utf8',

+ 1 - 0
frameworks/PHP/phalcon/app/config/config.php

@@ -7,6 +7,7 @@ return new \Phalcon\Config(array(
         'username' => 'benchmarkdbuser',
         'password' => 'benchmarkdbpass',
         'name'     => 'hello_world',
+        'persistent' => true,
     ),
     'mongodb'     => array(
         'url'     => 'mongodb://tfb-database:27017',

+ 1 - 0
frameworks/PHP/slim/index.php

@@ -8,6 +8,7 @@ $app = new Slim\App(array(
         $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world;charset=utf8', 'benchmarkdbuser', 'benchmarkdbpass');
         $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
+        $pdo->setAttribute(PDO::ATTR_PERSISTENT, true);
 
         return $pdo;
     },

+ 4 - 1
frameworks/PHP/zend/config/autoload/benchmarks.local.php

@@ -5,6 +5,9 @@ return array(
         'driver'   => 'Pdo',
         'dsn'      => 'mysql:dbname=hello_world;host=tfb-database;port=3306',
         'username' => 'benchmarkdbuser',
-        'password' => 'benchmarkdbpass'
+        'password' => 'benchmarkdbpass',
+        'driver_options' => array(
+             PDO::ATTR_PERSISTENT => true
+        ),
     ),
 );

+ 1 - 0
frameworks/PHP/zend1/application/configs/application.ini

@@ -13,6 +13,7 @@ resources.db.params.charset = "utf8"
 resources.db.params.dbname = "hello_world"
 resources.db.params.username = "benchmarkdbuser"
 resources.db.params.password = "benchmarkdbpass"
+resources.db.params.persistent = true
 
 [development : production]
 phpSettings.display_startup_errors = 1