<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>MAJ Stock</title>
		<link href="stock.css" rel="stylesheet" type="text/css">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	</head>
	<body>
		<?php
		$connexion = "host='192.168.0.11' dbname='PharmagedonDate' user='openpg' password='openpgpwd'";
		$c = pg_connect($connexion);
		$s = "select relname, attname from pg_attribute join pg_class on (relfilenode = attrelid) ";
		$s .= "join pg_tables on (relname = tablename) join pg_type on (typelem = atttypid) ";
		$s .= "where schemaname = 'public' and (typname like '_timestamp' or typname like '_date') ";
		$s .= "order by 1,2";	
		$r = pg_query($c, $s);
		$t = pg_fetch_all($r);
		echo "<ol>";
		foreach ($t as $lig)
			{
			$s_req = "update ".$lig["relname"]." set ";
			$s_req = $s_req.$lig["attname"]." = ".$lig["attname"]." + interval '52 weeks'";
			$r2 = pg_query($c,$s_req);
			echo "<li>MAJ ".$lig["relname"].".".$lig["attname"]." effectuée.</li>";
			}
		echo "</ol>";
		$b = pg_close($c);
		echo "<br>";
		echo "<br>";
		?>
	</body>
</html>