File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
app/code/core/Mage/Core/Model/Resource/Db Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -324,18 +324,30 @@ protected function _getConnection($connectionName)
324
324
return $ this ->_connections [$ connectionName ];
325
325
}
326
326
327
+ /**
328
+ * @param string $connectionName
329
+ * @return bool
330
+ */
331
+ public function hasConnection ($ connectionName )
332
+ {
333
+ return isset ($ this ->_connections [$ connectionName ]);
334
+ }
335
+
327
336
/**
328
337
* Retrieve connection for read data
329
338
*
330
339
* @return Magento_Db_Adapter_Pdo_Mysql
331
340
*/
332
341
protected function _getReadAdapter ()
333
342
{
334
- $ writeAdapter = $ this ->_getWriteAdapter ();
335
- if ($ writeAdapter && $ writeAdapter ->getTransactionLevel () > 0 ) {
336
- // if transaction is started we should use write connection for reading
337
- return $ writeAdapter ;
343
+ if ($ this ->hasConnection ('write ' )) {
344
+ $ writeAdapter = $ this ->_getWriteAdapter ();
345
+ if ($ writeAdapter && $ writeAdapter ->getTransactionLevel () > 0 ) {
346
+ // if transaction is started we should use write connection for reading
347
+ return $ writeAdapter ;
348
+ }
338
349
}
350
+
339
351
return $ this ->_getConnection ('read ' );
340
352
}
341
353
You can’t perform that action at this time.
0 commit comments