<?php

class situpat
{
	function get_situpat($id_consult)
	{
		$q = "SELECT * FROM situpat WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);

		if ($r)
		{
			$n = mysql_fetch_assoc($r);
			return $n;
		}
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());

		return false;
	}

	function edit_situpat($id_consult, $id_mod, $id_couv, $sit_ress, $sit_tutelle, $sit_prof, $sit_mat, $sit_enf, $sit_enfchg, $sit_fam, $sit_log, $sit_csp, $sit_etude, $sit_pec, $prop_tera = 0)
	{
		if ($id_consult)
			$this->del_situpat($id_consult);

		$q = "INSERT INTO situpat (id_consult, id_mod, id_couv, sit_ress, sit_tutelle, sit_prof, sit_mat, sit_enf, sit_enfchg, sit_fam, sit_log, sit_csp, sit_etude, sit_pec, prop_tera) VALUES ('" . $id_consult . "', '" . $id_mod . "', '" . $id_couv . "', '" . $sit_ress . "', '" . $sit_tutelle . "', '" . $sit_prof . "', '" . $sit_mat . "', '" . $sit_enf . "', '" . $sit_enfchg . "', '" . $sit_fam . "', '" . $sit_log . "', '" . $sit_csp . "', '" . $sit_etude . "', '" . $sit_pec . "', '" . $prop_tera . "')";
		$r = mysql_query($q);

		if ($r)
			return true;
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());

		return false;
	}

	function del_situpat($id_consult)
	{
		$q = "DELETE FROM situpat WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);

		if ($r)
		{
			$q = "OPTIMIZE TABLE situpat";
			$r = mysql_query($q);

			return true;
		}
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());

		return false;
	}
}

?>