summaryrefslogtreecommitdiff
path: root/src/model/Model.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/Model.php')
-rw-r--r--src/model/Model.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/model/Model.php b/src/model/Model.php
index 1fdab7d..fad25b3 100644
--- a/src/model/Model.php
+++ b/src/model/Model.php
@@ -64,8 +64,7 @@ abstract class Model extends DB
64 // méthode lancée par des objets de type enfants 64 // méthode lancée par des objets de type enfants
65 function hydrateFromForm(string $data_string, Object $Presta = NULL): bool // quand l'objet est $Details, on hydrate aussi $Presta 65 function hydrateFromForm(string $data_string, Object $Presta = NULL): bool // quand l'objet est $Details, on hydrate aussi $Presta
66 { 66 {
67 //~ $tableSize = count(StructTablesDB::$structureOfTables[$this->getTable()]); // int 67 $data_string = $this->cleanSpecialChars($data_string); // possibilité que $data_string devienne une chaine vide
68
69 if($data_string !== '') 68 if($data_string !== '')
70 { 69 {
71 $data_array = explode('|', $data_string); // array 70 $data_array = explode('|', $data_string); // array
@@ -130,13 +129,19 @@ abstract class Model extends DB
130 } 129 }
131 } 130 }
132 131
132 protected function cleanSpecialChars(string $data): string
133 {
134 $search = ['"'];
135 return str_replace($search, '', $data);
136 }
137
133 138
134 // exécuter le SQL 139 // exécuter le SQL
135 // les attributs correspondent aux ? dans les requêtes préparées 140 // les $attributs correspondent aux ? dans les requêtes préparées
136 // ne pas surcharger la méthode PDO::query() qui n'est pas compatible 141 // ne pas surcharger la méthode PDO::query() qui n'est pas compatible
137 protected function execQuery(string $sql, array $attributes = null) 142 protected function execQuery(string $sql, array $attributes = null)
138 { 143 {
139 $this->db = parent::getInstance(); // connexion 144 $this->db = parent::getInstance(); // parent::, self:: et DB:: sont équivalents
140 145
141 if($attributes !== null) // requête préparée 146 if($attributes !== null) // requête préparée
142 { 147 {