Phalcon 框架如何实现主从读写分离
假设你已经在 DI 容器里注册了俩 db services,如下: 1<?php 2// 主库 3$di->setShared('dbWrite', function() use ($config) { 4 return new \Phalcon\Db\Adapter\Pdo\Mysql(array( 5 "host" => $config->w_database->host, 6 "username" => $config->w_database->username, 7 "password" => $config->w_database->password, 8 "dbname" => $config->w_database->name 9 )); 10}); 11// 从库 12$di->setShared('dbRead', function() use ($config) { 13 return new...