function getProjectID($hash) { $hash = sqlSafe($hash); $query = "SELECT id FROM projects WHERE hash={$hash}"; $result = readQuery($query); if (hasSQLerrors()) { var_dump(getSQLerrors()); } if ($result) { while ($row = $result->fetch_assoc()) { return $row['id']; } } return null; }
function updateProj() { if (!isset($_GET['key'])) { $errors = array("source" => "main", "error" => "Key not set, exiting"); throwError($errors); } $key = $_GET['key']; if (!isset($_GET['value'])) { $value = ''; } else { $value = $_GET['value']; } $project = $_SESSION['project']; $query = "UPDATE projects SET " . sqlSafe($key, true) . " = " . sqlSafe($value) . " WHERE id = " . sqlSafe($project); writeQuery($query); if (hasSQLerrors()) { throwError(getSQLerrors()); } success(array('key' => $key, 'value' => $value, 'query' => $query)); }
function createRecords($record) { deleteExistingRecords($record); insertRecord($record); insertChildRecords($record); insertMeasurements($record); insertCreators($record); if (hasSQLerrors()) { deleteExistingRecords($record); throwError(getSQLerrors()); } else { attachObject($record); if (hasSQLerrors()) { throwError(getSQLerrors()); } return $record; } return null; }