浏览代码

Enable PDO persistent connections

Turn on persistent connections. Seems to result in noticeable speed improvements in my very unscientific local apachebench results.
Alan 12 年之前
父节点
当前提交
d854f07ee2
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      php-silex/web/index.php

+ 5 - 5
php-silex/web/index.php

@@ -9,13 +9,13 @@ require_once __DIR__.'/../vendor/autoload.php';
 
 $app = new Silex\Application();
 
+$dbh = new PDO('mysql:host=192.168.100.102;dbname=hello_world', 'benchmarkdbuser', 'benchmarkdbpass', array(
+    PDO::ATTR_PERSISTENT => true
+));
+
 $app->register(new Silex\Provider\DoctrineServiceProvider(), array(
     'db.options' => array(
-        'driver' => 'pdo_mysql',
-        'host' => '192.168.100.102',
-        'dbname' => 'hello_world',
-        'user' => 'benchmarkdbuser',
-        'password' => 'benchmarkdbpass',
+    'pdo' => $dbh
     ),
 ));