<?php

class structure
{
	function list_structure($id_consult)
	{
		$data = array();
	
		$q = "SELECT * FROM structure 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_structure($id_consult, $struct_type, $struct_add, $struct_date, $struct_interv, $struct_duree, $struct_res)
	{
		$q = "INSERT INTO structure (id_consult, struct_type, struct_add, struct_date, struct_interv, struct_duree, struct_res) VALUES ('" . $id_consult . "', '" . $struct_type . "' , '" . $struct_add . "' , '" . $struct_date . "' , '" . sqldata($struct_interv) . "' , '" . $struct_duree . "' , '" . $struct_res . "')";
		$r = mysql_query($q);
	
		if ($r) 
			return true;
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());
	
		return false;
	}

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

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

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

}

?>