s')"); pg_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('samedi à dimanche', 's->d')"); pg_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('dimanche à lundi', 'd->l')"); } function update_db() { # si la table 'config' n'existe pas alors on suppose qu'aucune table n'existe $version = 0; $res = @pg_fetch_object(pg_query("SELECT valeur FROM config WHERE nom = 'version'")); if (pg_result_status($res) != PGSQL_TUPLES_OK) $version = $res->valeur; if($version == 0) { echo "Création de la base de donnée, version = 1\n"; pg_query("BEGIN"); creer_db(); initialiser_db(); pg_query("COMMIT"); $version = 1; } # version 1 -> 2 (à utiliser pour une utilisation future) /* if ($version == 1) { pg_query("BEGIN"); # queries... pg_query("UPDATE config SET valeur = '2' WHERE nom = 'version'"); pg_query("COMMIT"); }*/ } update_db(); ?>