database error, can't connect."; die($sqliteerror); } } function db_update_target($array) { // form the request $sql = "UPDATE holigrail_targetmeasurements SET targetname='".$array['name']."', seeing='".$array['seeing']."', transparency='".$array['transparency']."', frames='".$array['numberOfFrames']."', comment='".$array['comment']."', date='".$array['date']."' WHERE id='".$array['id']."' "; // connect to db and send the informations, return id global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); return $array['id']; // returns the id of the updated data set } else { echo "

database error, can't connect.

"; die($sqliteerror); } } function db_delete_target($id) { // form the request $sql = "DELETE FROM holigrail_targetmeasurements WHERE id='".$id."' "; // connect to db and run sqlite command global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); } else { echo "

database error, can't connect.

"; die($sqliteerror); } } function db_put_observation($array) { // form the request $submitted = date('Y-m-d H:i:s'); $sql = "INSERT INTO holigrail_observations (id,submitted,date,sTime,fTime,nTime,targets,biasFrames,domeFlats,skyFlats,telescopeTemp,optimalFocus,refocused,problems,weather, observer) VALUES (NULL, '".$submitted."', '".$array['date']."', '".$array['sTime']."', '".$array['fTime']."', '".$array['nTime']."', '".$array['targets']."', '".$array['biasFrames']."', '".$array['domeFlats']."', '".$array['skyFlats']."', '".$array['telescopeTemp']."', '".$array['optimalFocus']."', '".$array['refocused']."', '".$array['problems']."', '".$array['weather']."', '".$array['observer']."'); "; // connect to db and send the informations, return id global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); $result = sqlite_query($db, "SELECT id FROM holigrail_observations WHERE submitted='".$submitted."' ORDER BY id DESC LIMIT 0, 1"); $last = sqlite_fetch_array($result); echo "

Observation #".$last[0]."

"; return $last[0]; // returns the id of the new data set } else { echo "

database error, can't connect.

"; die($sqliteerror); } } function db_update_observation($array) { // form the request $sql = "UPDATE holigrail_observations SET date='".$array['date']."', sTime='".$array['sTime']."', fTime='".$array['fTime']."', nTime='".$array['nTime']."', targets='".$array['targets']."', biasFrames='".$array['biasFrames']."', domeFlats='".$array['domeFlats']."', skyFlats='".$array['skyFlats']."', telescopeTemp='".$array['telescopeTemp']."', optimalFocus='".$array['optimalFocus']."', refocused='".$array['refocused']."', problems='".$array['problems']."', weather='".$array['weather']."', observer='".$array['observer']."' WHERE id='".$array['id']."' "; // connect to db and send the informations, return id global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); return $array['id']; } else { echo "

database error, can't connect.

"; die($sqliteerror); } } // get data ouot of your db with a certain key/value-pair function db_get_last_observations($n) { $sql = "SELECT * FROM holigrail_observations ORDER BY id DESC LIMIT 0, ".$n.""; // send request global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); return $result; } else { echo "

database error, can't connect.

"; die($sqliteerror); } } function db_get_targets($ids) { if ($ids != '') { $idlist = str_replace(",", " OR id=", $ids); $sql = "SELECT * FROM holigrail_targetmeasurements WHERE id=".$idlist; // send request global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); return $result; } else { echo "

database error, can't connect.

"; die($sqliteerror); } } else return ''; } function db_get_certain_observations($id) { if ($id != '') { $sql = "SELECT * FROM holigrail_observations WHERE id=".$id; // send request global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); return $result; } else { echo "

database error, can't connect.

"; die($sqliteerror); } } else return ''; } function db_get_certain_observations_by_date($date) { if ($date != '') { $sql = "SELECT * FROM holigrail_observations WHERE date='".$date."';"; // send request global $config; $dbfile = $config['sqlite_file']; if ($db = sqlite_open($dbfile, 0666, $sqliteerror)) { $result = sqlite_query($db, $sql); return $result; } else { echo "

database error, can't connect.

"; die($sqliteerror); } } else return ''; } ?> Homepage of the HOLIGRAIL Project