@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | use \Exception; |
| 34 | 34 | |
| 35 | -require_once dirname(__DIR__) . "/config/_config.php"; |
|
| 35 | +require_once dirname(__DIR__)."/config/_config.php"; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * This class is a singleton for establishing a connection to the database |
@@ -61,24 +61,24 @@ discard block |
||
| 61 | 61 | case "EXTERNAL": |
| 62 | 62 | case "FRONTEND": |
| 63 | 63 | case "DIAGNOSTICS": |
| 64 | - if (!isset(self::${"instance" . $theDb})) { |
|
| 64 | + if (!isset(self::${"instance".$theDb})) { |
|
| 65 | 65 | $class = __CLASS__; |
| 66 | - self::${"instance" . $theDb} = new $class($database); |
|
| 67 | - DBConnection::${"instance" . $theDb}->databaseInstance = $theDb; |
|
| 66 | + self::${"instance".$theDb} = new $class($database); |
|
| 67 | + DBConnection::${"instance".$theDb}->databaseInstance = $theDb; |
|
| 68 | 68 | } |
| 69 | - return self::${"instance" . $theDb}; |
|
| 69 | + return self::${"instance".$theDb}; |
|
| 70 | 70 | case "RADIUS": |
| 71 | - if (!isset(self::${"instance" . $theDb})) { |
|
| 71 | + if (!isset(self::${"instance".$theDb})) { |
|
| 72 | 72 | $class = __CLASS__; |
| 73 | 73 | foreach (CONFIG_CONFASSISTANT['DB'] as $name => $oneRadiusAuthDb) { |
| 74 | 74 | $theInstance = new $class($name); |
| 75 | - self::${"instance" . $theDb}[] = $theInstance; |
|
| 75 | + self::${"instance".$theDb}[] = $theInstance; |
|
| 76 | 76 | $theInstance->databaseInstance = $theDb; |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | - return self::${"instance" . $theDb}; |
|
| 79 | + return self::${"instance".$theDb}; |
|
| 80 | 80 | default: |
| 81 | - throw new Exception("This type of database (" . strtoupper($database) . ") is not known!"); |
|
| 81 | + throw new Exception("This type of database (".strtoupper($database).") is not known!"); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -117,18 +117,18 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | // log exact query to debug log, if log level is at 5 |
| 120 | - $this->loggerInstance->debug(5, "DB ATTEMPT: " . $querystring . "\n"); |
|
| 120 | + $this->loggerInstance->debug(5, "DB ATTEMPT: ".$querystring."\n"); |
|
| 121 | 121 | if ($types !== NULL) { |
| 122 | - $this->loggerInstance->debug(5, "Argument type sequence: $types, parameters are: " . print_r($arguments, true)); |
|
| 122 | + $this->loggerInstance->debug(5, "Argument type sequence: $types, parameters are: ".print_r($arguments, true)); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if ($this->connection->connect_error) { |
| 126 | - throw new Exception("ERROR: Cannot send query to $this->databaseInstance database (no connection, error number" . $this->connection->connect_error . ")!"); |
|
| 126 | + throw new Exception("ERROR: Cannot send query to $this->databaseInstance database (no connection, error number".$this->connection->connect_error.")!"); |
|
| 127 | 127 | } |
| 128 | 128 | if ($types === NULL) { |
| 129 | 129 | $result = $this->connection->query($querystring); |
| 130 | 130 | if ($result === FALSE) { |
| 131 | - throw new Exception("DB: Unable to execute simple statement! Error was --> " . $this->connection->error . " <--"); |
|
| 131 | + throw new Exception("DB: Unable to execute simple statement! Error was --> ".$this->connection->error." <--"); |
|
| 132 | 132 | } |
| 133 | 133 | } else { |
| 134 | 134 | // fancy! prepared statement with dedicated argument list |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | $prepResult = $statementObject->prepare($querystring); |
| 143 | 143 | if ($prepResult === FALSE) { |
| 144 | - throw new Exception("DB: Unable to prepare statement! Statement was --> $querystring <--, error was --> " . $statementObject->error . " <--."); |
|
| 144 | + throw new Exception("DB: Unable to prepare statement! Statement was --> $querystring <--, error was --> ".$statementObject->error." <--."); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // we have a variable number of arguments packed into the ... array |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | array_unshift($localArray, $types); |
| 154 | 154 | $retval = call_user_func_array([$statementObject, "bind_param"], $localArray); |
| 155 | 155 | if ($retval === FALSE) { |
| 156 | - throw new Exception("DB: Unable to bind parameters to prepared statement! Argument array was --> " . var_export($localArray, TRUE) . " <--. Error was --> " . $statementObject->error . " <--"); |
|
| 156 | + throw new Exception("DB: Unable to bind parameters to prepared statement! Argument array was --> ".var_export($localArray, TRUE)." <--. Error was --> ".$statementObject->error." <--"); |
|
| 157 | 157 | } |
| 158 | 158 | $result = $statementObject->execute(); |
| 159 | 159 | if ($result === FALSE) { |
| 160 | - throw new Exception("DB: Unable to execute prepared statement! Error was --> " . $statementObject->error . " <--"); |
|
| 160 | + throw new Exception("DB: Unable to execute prepared statement! Error was --> ".$statementObject->error." <--"); |
|
| 161 | 161 | } |
| 162 | 162 | $selectResult = $statementObject->get_result(); |
| 163 | 163 | if ($selectResult !== FALSE) { |
@@ -169,14 +169,14 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | // all cases where $result could be FALSE have been caught earlier |
| 171 | 171 | if ($this->connection->errno) { |
| 172 | - throw new Exception("ERROR: Cannot execute query in $this->databaseInstance database - (hopefully escaped) query was '$querystring', errno was " . $this->connection->errno . "!"); |
|
| 172 | + throw new Exception("ERROR: Cannot execute query in $this->databaseInstance database - (hopefully escaped) query was '$querystring', errno was ".$this->connection->errno."!"); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | if ($isMoreThanSelect) { |
| 177 | - $this->loggerInstance->writeSQLAudit("[DB: " . strtoupper($this->databaseInstance) . "] " . $querystring); |
|
| 177 | + $this->loggerInstance->writeSQLAudit("[DB: ".strtoupper($this->databaseInstance)."] ".$querystring); |
|
| 178 | 178 | if ($types !== NULL) { |
| 179 | - $this->loggerInstance->writeSQLAudit("Argument type sequence: $types, parameters are: " . print_r($arguments, true)); |
|
| 179 | + $this->loggerInstance->writeSQLAudit("Argument type sequence: $types, parameters are: ".print_r($arguments, true)); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | return $result; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $this->readOnly = CONFIG_CONFASSISTANT['DB'][$databaseCapitalised]['readonly']; |
| 274 | 274 | } |
| 275 | 275 | if ($this->connection->connect_error) { |
| 276 | - throw new Exception("ERROR: Unable to connect to $database database! This is a fatal error, giving up (error number " . $this->connection->connect_errno . ")."); |
|
| 276 | + throw new Exception("ERROR: Unable to connect to $database database! This is a fatal error, giving up (error number ".$this->connection->connect_errno.")."); |
|
| 277 | 277 | } |
| 278 | 278 | // it does not matter for internal time calculations with TIMESTAMPs but |
| 279 | 279 | // sometimes we operate on date/time strings. Since MySQL returns those |