Exemple #1
0
 /**
  * Returns either the master or slave db connection based on the query being run
  * @param string $query
  * @return \mysqli
  */
 protected function chooseDbByQuery($query)
 {
     if ($this->dbSlave == null) {
         return $this->dbMaster;
     }
     if ($this->forceMaster) {
         return $this->dbMaster;
     }
     if (Str::startsWithInsensitive(ltrim($query), 'select ') && !$this->isSelectIntoQuery($query)) {
         return $this->dbSlave;
     }
     return $this->dbMaster;
 }