@@ -83,28 +83,6 @@ public static function createConnection($servers, array $options = array())
8383$ client =new \Memcached ($ options ['persistent_id ' ]);
8484$ username =$ options ['username ' ];
8585$ password =$ options ['password ' ];
86- unset($ options ['persistent_id ' ],$ options ['username ' ],$ options ['password ' ]);
87- $ options =array_change_key_case ($ options ,CASE_UPPER );
88-
89- // set client's options
90- $ client ->setOption (\Memcached::OPT_BINARY_PROTOCOL ,true );
91- $ client ->setOption (\Memcached::OPT_NO_BLOCK ,true );
92- if (!array_key_exists ('LIBKETAMA_COMPATIBLE ' ,$ options ) && !array_key_exists (\Memcached::OPT_LIBKETAMA_COMPATIBLE ,$ options )) {
93- $ client ->setOption (\Memcached::OPT_LIBKETAMA_COMPATIBLE ,true );
94- }
95- foreach ($ optionsas $ name =>$ value ) {
96- if (is_int ($ name )) {
97- continue ;
98- }
99- if ('HASH ' ===$ name ||'SERIALIZER ' ===$ name ||'DISTRIBUTION ' ===$ name ) {
100- $ value =constant ('Memcached:: ' .$ name .'_ ' .strtoupper ($ value ));
101- }
102- $ opt =constant ('Memcached::OPT_ ' .$ name );
103-
104- unset($ options [$ name ]);
105- $ options [$ opt ] =$ value ;
106- }
107- $ client ->setOptions ($ options );
10886
10987// parse any DSN in $servers
11088foreach ($ serversas $ i =>$ dsn ) {
@@ -139,11 +117,34 @@ public static function createConnection($servers, array $options = array())
139117if (isset ($ params ['query ' ])) {
140118parse_str ($ params ['query ' ],$ query );
141119$ params +=$ query ;
120+ $ options +=$ query ;
142121 }
143122
144123$ servers [$ i ] =array ($ params ['host ' ],$ params ['port ' ],$ params ['weight ' ]);
145124 }
146125
126+ // set client's options
127+ unset($ options ['persistent_id ' ],$ options ['username ' ],$ options ['password ' ],$ options ['weight ' ]);
128+ $ options =array_change_key_case ($ options ,CASE_UPPER );
129+ $ client ->setOption (\Memcached::OPT_BINARY_PROTOCOL ,true );
130+ $ client ->setOption (\Memcached::OPT_NO_BLOCK ,true );
131+ if (!array_key_exists ('LIBKETAMA_COMPATIBLE ' ,$ options ) && !array_key_exists (\Memcached::OPT_LIBKETAMA_COMPATIBLE ,$ options )) {
132+ $ client ->setOption (\Memcached::OPT_LIBKETAMA_COMPATIBLE ,true );
133+ }
134+ foreach ($ optionsas $ name =>$ value ) {
135+ if (is_int ($ name )) {
136+ continue ;
137+ }
138+ if ('HASH ' ===$ name ||'SERIALIZER ' ===$ name ||'DISTRIBUTION ' ===$ name ) {
139+ $ value =constant ('Memcached:: ' .$ name .'_ ' .strtoupper ($ value ));
140+ }
141+ $ opt =constant ('Memcached::OPT_ ' .$ name );
142+
143+ unset($ options [$ name ]);
144+ $ options [$ opt ] =$ value ;
145+ }
146+ $ client ->setOptions ($ options );
147+
147148// set client's servers, taking care of persistent connections
148149if (!$ client ->isPristine ()) {
149150$ oldServers =array ();