<?php

class rosace
{
	function get_rosace($id_consult)
	{
		$q = "SELECT * FROM rosace 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_rosace($id_consult, $eval_qv, $eval_alcool, $eval_tabac, $eval_canabis, $eval_mesusmedi, $eval_prodill, $eval_troublcond, $eval_probjudi, $eval_probpro, $eval_probsoc, $eval_probfam, $eval_etatpsy, $eval_etatsoma, $eval_motiv)
	{
		if ($id_consult)
			$this->del_rosace($id_consult);

		$q = "INSERT INTO rosace (id_consult, eval_qv, eval_alcool, eval_tabac, eval_canabis, eval_mesusmedi, eval_prodill, eval_troublcond, eval_probjudi, eval_probpro, eval_probsoc, eval_probfam, eval_etatpsy, eval_etatsoma, eval_motiv) VALUES ('" . $id_consult . "', '" . $eval_qv . "' , '" . $eval_alcool . "' , '" . $eval_tabac . "' , '" . $eval_canabis . "' , '" . $eval_mesusmedi . "' , '" . $eval_prodill . "' , '" . $eval_troublcond . "' , '" . $eval_probjudi . "' , '" . $eval_probpro . "' , '" . $eval_probsoc . "' , '" . $eval_probfam . "' , '" . $eval_etatpsy . "' , '" . $eval_etatsoma . "' , '" . $eval_motiv . "')";
		$r = mysql_query($q);
	
		if ($r) 
			return true;
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());
	
		return false;
	}

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

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

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

		return false;
	}

}

?>