Hi,
I'm trying to use rcube_mdb2 to connect to another database. I need to connect to one database to execute insert/update/delete statements and to another database to execute select statements (performance reasons). I'm passing the second dsn to rcube_mdb2 constructor, but if the database is connected to the readonly db and I call db_connect("w"), the connection remains on readonly db and my insert statement fails. If I set db_connected to false on mdb2 object before db_connect("w") call, I got the new connection as desired. Is this a bug ?
Tks.
On 20.08.2010 02:16, Emerson Pinter wrote:
I'm trying to use rcube_mdb2 to connect to another database. I need to connect to one database to execute insert/update/delete statements and to another database to execute select statements (performance reasons). I'm passing the second dsn to rcube_mdb2 constructor, but if the database is connected to the readonly db and I call db_connect("w"), the connection remains on readonly db and my insert statement fails. If I set db_connected to false on mdb2 object before db_connect("w") call, I got the new connection as desired.
Are you sure this is the reason? Did you add "?new_link=true" to DSN of second connection?
With or without new_link=true, I get the same error...
On Fri, 20 Aug 2010 08:09:14 +0200, "A.L.E.C" alec@alec.pl wrote:
On 20.08.2010 02:16, Emerson Pinter wrote:
I'm trying to use rcube_mdb2 to connect to another database. I need to connect to one database to execute insert/update/delete statements and to another database to execute select statements (performance reasons). I'm passing the second dsn to rcube_mdb2 constructor, but if the database is connected to the readonly db and I call db_connect("w"), the connection remains on readonly db and my insert statement fails. If I set db_connected to false on mdb2 object before db_connect("w") call, I got the new connection as desired.
Are you sure this is the reason? Did you add "?new_link=true" to DSN of second connection?
List info: http://lists.roundcube.net/dev/ BT/aba52c80
On Fri, Aug 20, 2010 at 02:16, Emerson Pinter epinter@picturecorp.com.br wrote:
Hi,
I'm trying to use rcube_mdb2 to connect to another database. I need to connect to one database to execute insert/update/delete statements and to another database to execute select statements (performance reasons). I'm passing the second dsn to rcube_mdb2 constructor, but if the database is connected to the readonly db and I call db_connect("w"), the connection remains on readonly db and my insert statement fails. If I set db_connected to false on mdb2 object before db_connect("w") call, I got the new connection as desired. Is this a bug ?
I think this is a bug. When I look at the code, in db_connect() we do $this->db_mode = $mode right at the beginning and later we have if ($this->db_mode == 'w') return;
Having $this->db_mode = $mode set at the end of the procedure would be correct.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80
On 18.09.2010 19:12, Thomas Bruederli wrote:
I think this is a bug. When I look at the code, in db_connect() we do $this->db_mode = $mode right at the beginning and later we have if ($this->db_mode == 'w') return;
Having $this->db_mode = $mode set at the end of the procedure would be correct.
Problem is because rcube_mdb2 stores DB handle in one variable. So, it is overwritten.
On Mon, Sep 20, 2010 at 8:25 AM, A.L.E.C alec@alec.pl wrote:
On 18.09.2010 19:12, Thomas Bruederli wrote:
I think this is a bug. When I look at the code, in db_connect() we do $this->db_mode = $mode right at the beginning and later we have if ($this->db_mode == 'w') return;
Having $this->db_mode = $mode set at the end of the procedure would be correct.
Problem is because rcube_mdb2 stores DB handle in one variable. So, it is overwritten.
I don't think this is a problem. The behavior sould be: Connect to read-only DB first and switch to read-write connection when the first write operation is to be done. From that time on, also read operations can be performed on the read-write connection. This is exactly what if ($this->db_mode == 'w') return; tries to achieve. Unfortunately the whole logic doesn't work at all because rcmail::get_dbh() opens a read-write connection right from the beginning.
I'll try to fix this in rcube_mdb2 class.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80