From a2fdd37ffb5a3cc80b6fedb332024057553148f8 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 27 Nov 2022 02:34:34 +0100 Subject: =?UTF-8?q?connexion=20BDD=20orient=C3=A9e=20objet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/Model.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 php/Model.php (limited to 'php/Model.php') diff --git a/php/Model.php b/php/Model.php new file mode 100644 index 0000000..9d0f80f --- /dev/null +++ b/php/Model.php @@ -0,0 +1,42 @@ +db = parent::getInstance(); + self::create_tables(); + } + + // code SQL + function create_tables() + { + // la table prestations est liée à la table clients + // les tables devis_factures, cesu et locations sont liées à la table prestations + $this->db->exec("CREATE TABLE IF NOT EXISTS clients (ID INTEGER, prenom_nom TEXT, adresse TEXT, code_client TEXT, commentaires TEXT, PRIMARY KEY(ID AUTOINCREMENT));"); + $this->db->exec("CREATE TABLE IF NOT EXISTS prestations (ID INTEGER, ID_client INTEGER, combientieme_fois INTEGER, code_presta TEXT, date INTEGER, type TEXT, mode_paiement TEXT, commentaires TEXT, PRIMARY KEY(ID AUTOINCREMENT));"); + $this->db->exec("CREATE TABLE IF NOT EXISTS devis_factures (ID INTEGER, ID_presta INTEGER, validite_devis TEXT, signature_devis TEXT, taches TEXT, machine TEXT, OS TEXT, donnees TEXT, cles_licences TEXT, total_main_d_oeuvre INTEGER, pieces TEXT, total_pieces INTEGER, deplacement INTEGER, total_HT INTEGER, PRIMARY KEY(ID AUTOINCREMENT));"); + $this->db->exec("CREATE TABLE IF NOT EXISTS cesu (ID INTEGER, ID_presta INTEGER, taches TEXT, duree_travail TEXT, salaire INTEGER, PRIMARY KEY(ID AUTOINCREMENT));"); + $this->db->exec("CREATE TABLE IF NOT EXISTS locations (ID INTEGER, ID_presta INTEGER, nature_bien TEXT, valeur INTEGER, etat_des_lieux_debut TEXT, etat_des_lieux_fin TEXT, total_HT INTEGER, PRIMARY KEY(ID AUTOINCREMENT));"); + + // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique + // le "type indiqué" est indiqué dans l'instruction CREATE TABLE + // https://www.leppf.com/site/spip.php?article89 + + // || type indiqué || type choisi automatiquement || autre types possibles || + // --------------------------------------------------------------------------- + // || TEXT || TEXT || BLOB, NULL || + // || INTEGER || INTEGER (de 1 à 8 octets) || REAL, TEXT, BLOB, NULL || + // || REAL || REAL (flottant sur 9 octets) || TEXT, BLOB, NULL || + // || NUMERIC || INTEGER ou REAL || TEXT, BLOB, NULL || + // || NONE || indéfini || dépend des données || + + // du code SQL écrit pour d'autres SGBD devrait fonctionner, + // sqlite fera des conversions dans ses propres types avec les problèmes qu'on peut imaginer + + // pour les dates, on stockera à priori le timestamp + } +} -- cgit v1.2.3