function _sync_cb_table(&$env, $oldrow) { global $SYNC_STATUS; global $ERROR; global $debug; $src = $env["SRC"]; $dst = $env["DST"]; $transl = $env["TRANSL"]; $modes = $env["MODES"]; if ($transl) { $newrow = $transl($oldrow); } else { $newrow = $oldrow; } if ($debug) { echo "sync_data: "; print_r($newrow); echo "<br>\n"; } $data = array($newrow); $qstruct = array("TABLE" => $dst, "MODE" => "REPLACE", "DATA" => $data, "CB" => "_db_cb_update", "TEST_MODE" => array("EXISTS", "DO_UPDATE"), "RAW_MODE" => true); $ok = _db_update($qstruct); if ($ok) { $old_stamp = $env["MAXTIME"]; $new_stamp = @$oldrow[$env["version"]]; $old = strtotime($old_stamp); $new = strtotime($new_stamp); echo "{$src} old = {$old_stamp} ({$old}) => {$dst} new = {$new_stamp} ({$new})\n"; if ($new > $old) { $env["MAXTIME"] = $new_stamp; } } else { echo "ERROR: {$ERROR}\n"; } return null; // don't aggregate results in the specific driver }
function db_update_users($k, $tbl, $hash, $where) { return _db_update($tbl, $hash, $where, 'users', $k); }
function db_update($tbl, $hash, $where){ return _db_update($tbl, $hash, $where, 'main'); }
function db_delete($tp_table, $data) { $qstruct = array("TABLE" => $tp_table, "MODE" => "DELETE", "DATA" => $data, "CB" => "_db_cb_update", "TEST_MODE" => array("EXISTS", "DO_UPDATE")); return _db_update($qstruct); }