// Make sure a potentially large XML based DataSource have sufficient memory to process data if ($res === false && $mem >= 128) { $mem = $mem / 2; $res = ini_set("memory_limit", $mem . "M"); if ($res === false) { $mem = $mem / 2; ini_set("memory_limit", $mem . "M"); } } } if ($ds->GetDataSourceType() === SMDataSourceType::$Xml && in_array($command, $dsDef["XmlLockRequired"]) === true) { $ds->Lock(); } // Make sure two sessions do not write data at the same time, potentially causing session X to overwrite data from session Y // Check weather item exists for Create/Retrieve/Update/Delete $exists = $ds->Count("Id = '" . $ds->Escape($props["Id"]) . "'") > 0; if ($command === "Create" && $exists === true) { header("HTTP/1.1 500 Internal Server Error"); echo "Operation '" . $command . "' failed - " . $model . " item with ID '" . $props["Id"] . "' already exists"; exit; } if (($command === "Retrieve" || $command === "Update" || $command === "Delete") && $exists === false) { header("HTTP/1.1 500 Internal Server Error"); echo "Operation '" . $command . "' failed - " . $model . " item with ID '" . $props["Id"] . "' could not be found"; exit; } // Update data source if ($command === "Create") { $item = new SMKeyValueCollection(); foreach ($props as $prop => $val) { if (isset($dsDef["Fields"][$prop]["ForceInitialValue"]) === true) {