diff options
Diffstat (limited to 'src/model/Clients.php')
-rw-r--r-- | src/model/Clients.php | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/model/Clients.php b/src/model/Clients.php index 816cff3..92a4b31 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
@@ -46,10 +46,36 @@ class Clients extends Model | |||
46 | } | 46 | } |
47 | 47 | ||
48 | 48 | ||
49 | public function newRow(array $entry) | 49 | public function newRow(array $input) |
50 | { | 50 | { |
51 | $this->hydrate(['prenom_nom' => $entry[0], 'adresse' => $entry[1], 'code_client' => $entry[2], 'commentaires' => $entry[3]]); | 51 | $this->hydrate(['prenom_nom' => $input[0], 'adresse' => $input[1], 'code_client' => $input[2], 'commentaires' => $input[3]]); |
52 | $this->create(); | 52 | $this->create(); |
53 | $this->setIdFromLastInsertID(); | 53 | $this->setIdFromLastInsertID(); // dans ModelChildren, n'utilise pas Model::execQuery() |
54 | } | ||
55 | |||
56 | public function findByKeywords(array $keywords, string $field): array | ||
57 | { | ||
58 | $result = []; | ||
59 | for($i = 0; $i < count($keywords); $i++) | ||
60 | { | ||
61 | // tableau à deux dimensions obtenu pour un mot clé | ||
62 | $query_result = $this->execQuery('SELECT * FROM ' . $this->table . ' WHERE ' . $field . ' LIKE "%' . $keywords[$i] . '%"')->fetchAll(); | ||
63 | foreach($query_result as $one_array) // pour chaque sous tableau | ||
64 | { | ||
65 | $already_exist = false; | ||
66 | for($j = 0; $j < count($result); $j++) // pour chaque tableau déjà enregistré dans le tableau $result | ||
67 | { | ||
68 | if($result[$j]['ID'] === $one_array['ID']) | ||
69 | { | ||
70 | $already_exist = true; | ||
71 | } | ||
72 | } | ||
73 | if(!$already_exist) | ||
74 | { | ||
75 | $result[] = $one_array; | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | return($result); | ||
54 | } | 80 | } |
55 | } | 81 | } |