<?php require_once dirname(__FILE__) . '/common/common.inc.php'; require_once dirname(__FILE__) . "/database/{$database}/database.inc.php"; header('Content-Type: text/plain'); $class = MiscUtils::decryptParam('name', NULL); $objectsToAddOrUpdate = json_decode(MiscUtils::decryptParam('o', NULL)); $objectsToRemove = json_decode(MiscUtils::decryptParam('r', NULL)); $orm = classToOrm($class); if ($orm) { try { $myManager->start_t(); foreach ($objectsToAddOrUpdate as &$object) { if (isset($object->id)) { $orm->update($myManager, $object); } else { $orm->add($myManager, $object); } } foreach ($objectsToRemove as &$object) { $orm->remove($myManager, $object); } $myManager->commit_t(); echo MiscUtils::encode(array()); } catch (PDOException $e) { echo MiscUtils::encode($e->getMessage()); } }
function succeeded($myManager) { $args = json_decode(MiscUtils::decryptParam('a', '[]')); $orm = classToOrm('pz_operation'); $orm1 = classToOrm('pz_visitor'); if ($orm && $orm1) { try { if ($args->operation != NULL) { $orm->add($myManager, $args->operation); } if ($args->visitor) { $orm1->update($myManager, $args->visitor); } $myManager->commit_t(); $myManager->start_t(); echo json_encode(array()); } catch (PDOException $e) { echo $e->getMessage(); } } }