コード例 #1
0
$error = '';
$logService = new LogDataService();
$ds = new PovDataService($conf['rep_source_dsn'], $conf['rep_source_dbname'], $conf['rep_source_dbpassword'], array(PDO::ATTR_PERSISTENT => false));
$rds = new ReplicationDataService($conf['rep_target_dsn'], $conf['rep_target_dbname'], $conf['rep_target_dbpassword'], array(PDO::ATTR_PERSISTENT => false));
for ($i = 0; $i < 1000; $i++) {
    $x = $ds->getNextXfer();
    if (!$x) {
        sleep(60);
        exit;
    }
    $table = $x['table'];
    $xid = $x['xid'];
    $action = $x['action'];
    $id = $x['id'];
    if ($action < 3) {
        $row = $ds->getXferRow($table, $xid);
        if (!$row) {
            $ds->deleteXfer($id);
            continue;
        }
    }
    switch ($action) {
        case 1:
            $rds->insertRow($table, $row);
            break;
        case 2:
            $rds->updateRow($table, $row);
            break;
        case 3:
            $rds->deleteRow($table, $xid);
            break;