读取 mysql binlog 开始和结束时间(4)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-26 11:01 点击:次
}
$next_filename = substr($buf, $i + 1);
$head_str = substr($buf, $i + 1 - $size_pos - self::EVENT_HEAD_SIZE, self::EVENT_HEAD_SIZE);
$head = unpack($this->eventHeadPackStr, $head_str);
if ($head['type_code'] != self::ROTATE_EVENT) {
return null;
}
return array('head'=>$head, 'nextFile'=>$next_filename);
}
/**
* @param string $path path to binlog file
*/
function read($path) {
$file = fopen($path, 'r');
if (!$file) {
return null;
}
if (!$this->isBinlog($file)) {
fclose($file);
return null;
}
$fde = $this->readFormatDescriptionEvent($file);
$re = $this->readRotateEvent($file);
fclose($file);
return array(
'beginAt' => $fde['head']['timestamp'],
'endAt' => $re['head']['timestamp'],
'nextFile' => $re['nextFile'],
'serverVersion' => $fde['data']['server_version'],
);
}
}
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>