clarkk clarkk - 1 month ago 24
PHP Question

Show mysql replication slave status

How to return the replication server status?

When trying to get the slave status nothing is returned?!

mysql: 5.1.63-0

code



$result = Mysql::result("SHOW SLAVE STATUS");
$status = $result->fetch_assoc();
echo '<pre>';
echo 'result: ';
print_r($result);
echo 'status: ';
print_r($status);
echo '</pre>';


returns



result: mysqli_result Object
(
[current_field] => 0
[field_count] => 38
[lengths] =>
[num_rows] => 0
[type] => 0
)
status:

Answer

You need to get the row with the data in it:

$row=$result->fetch_assoc()

Then $row['Slave_IO_Running'] and $row ['Slave_SQL_Running'] should give you what you need. Both should be yes.

Comments