Issue in Aura\Sql\ConnectionManager

14 views
Skip to first unread message

Roy Gu

unread,
Mar 23, 2012, 1:08:54 AM3/23/12
to aur...@googlegroups.com
HI, I am using package Aura\Sql. And met a problem.
 
I have 2 Db masters, so i set array $arrMasters like this:
$arrMasters[0] = array(...);
$arrMasters[1] = array(...);
 
when i want to get the first master, i tried to use $conn->getMaster(0), and it returned a random result...
 
i think the problem is the if clause.
 
public function getMaster($name = null)
 {
     if ( ! $name) {
         ...
     }
}
 
it should be like this:
 
public function getMaster($name = null)
{
    if ( $name === null) {
        ...
    }
}
 
and same problem in getSlave().
 
 
Thanks~

Roy Gu

Hari K T

unread,
Apr 17, 2012, 6:01:59 AM4/17/12
to aur...@googlegroups.com
Hi Roy Gu,

Aaah sorry for the late reply. I saw the mail and was busy at the time. But later looking I didn't see the mail and thought I saw a dream :-) .

Ok coming to the issue .

Hari K T
M: +91-9388758821 | W: http://harikt.com/blog



On Fri, Mar 23, 2012 at 10:38 AM, Roy Gu <cnw...@gmail.com> wrote:
HI, I am using package Aura\Sql. And met a problem.
 
I have 2 Db masters, so i set array $arrMasters like this:
$arrMasters[0] = array(...);
$arrMasters[1] = array(...);
 
when i want to get the first master, i tried to use $conn->getMaster(0), and it returned a random result...
 
i think the problem is the if clause.
 
public function getMaster($name = null)
 {
     if ( ! $name) {

The problem is your array's key is 0 and ! 0 is 1  :-)
 
         ...
     }
}
 
it should be like this:
 
public function getMaster($name = null)
{
    if ( $name === null) {

Yes I think this is a fix . Good thought :-) .
 
        ...
    }
}
 
and same problem in getSlave().
 
Understood .

Why not giving a PR  ( Pull Request ) ? 

Fork it and create a branch with the name and make the changes and give a pull request from that branch to master of Aura.Sql .

 
Thanks~

Roy Gu

Reply all
Reply to author
Forward
0 new messages