<?php

class drogue
{
	function get_drogue($id_consult)
	{
		$q = "SELECT * FROM drogue 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_drogue($id_consult, $drog_canabis, $drog_heroine, $drog_codeine, $drog_opium, $drog_lsd, $drog_hallu, $drog_colle, $drog_amphe, $drog_mdma, $drog_stimul, $drog_stimul_desc, $drog_coke, $drog_crack, $drog_autre, $drog_autre_desc, $drog_intra)
	{
		if ($id_consult)
			$this->del_drogue($id_consult);

		$q = "INSERT INTO drogue (id_consult, drog_canabis, drog_heroine, drog_codeine, drog_opium, drog_lsd, drog_hallu, drog_colle, drog_amphe, drog_mdma, drog_stimul, drog_stimul_desc, drog_coke, drog_crack, drog_autre, drog_autre_desc, drog_intra) VALUES ('" . $id_consult . "', '" . $drog_canabis . "', '" . $drog_heroine . "', '" . $drog_codeine . "', '" . $drog_opium . "', '" . $drog_lsd . "', '" . $drog_hallu . "', '" . $drog_colle . "', '" . $drog_amphe . "', '" . $drog_mdma . "', '" . $drog_stimul . "', '" . sqldata($drog_stimul_desc) . "', '" . $drog_coke . "', '" . $drog_crack . "', '" . $drog_autre . "', '" . sqldata($drog_autre_desc) . "', '" . $drog_intra . "')";
		$r = mysql_query($q);
	
		if ($r) 
			return true;
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());
	
		return false;
	}

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

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

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

		return false;
	}
}

?>