<?php

class activite
{
	function get_activite($id_consult)
	{
		$data = array();

		$q = "SELECT * FROM activite WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);

		if ($r)
		{
			if ($t = mysql_num_rows($r))
			{
				while ($n = mysql_fetch_assoc($r))
					$data[] = $n;
			}
		}
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());

		return $data;
	}

	function edit_activite($id_consult, $id_act, $act_prescrit, $act_effectue)
	{
		$q = "INSERT INTO activite (id_consult, id_act, act_prescrit, act_effectue) VALUES ('" . $id_consult . "', '" . $id_act . "', '" . sql_date($act_prescrit) . "', '" . sql_date($act_effectue) . "')";
		$r = mysql_query($q);

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

		return false;
	}

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

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

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

		return false;
	}
}

?>