| Conditions | 5 |
| Paths | 5 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function run() |
||
| 29 | { |
||
| 30 | $mysqli = new \mysqli($this->host, $this->userName, $this->password); |
||
| 31 | |||
| 32 | if ($mysqli->connect_errno) { |
||
| 33 | return new Result(Result::STATUS_FAIL, sprintf("Connect failed: %s\n", $mysqli->connect_error)); |
||
| 34 | } |
||
| 35 | |||
| 36 | $result = $mysqli->query("SHOW SLAVE STATUS"); |
||
| 37 | |||
| 38 | $fields = $result->fetch_assoc(); |
||
| 39 | |||
| 40 | if (is_array($fields)) { |
||
| 41 | if (array_key_exists($this->field, $fields)) { |
||
| 42 | if ($fields[$this->field] == $this->value) { |
||
| 43 | return new Result(Result::STATUS_PASS, 'Field "' . $this->field . '" has value "' . $this->value . '" which was expected.'); |
||
| 44 | } else { |
||
| 45 | return new Result(Result::STATUS_FAIL, 'Field "' . $this->field . '" has value ' . $fields[$this->field] . '. Expected was "' . $this->value . '"'); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return new Result(Result::STATUS_FAIL, 'Field "' . $this->field . '" was not found in database slave status.'); |
||
| 51 | } |
||
| 58 |