소스 검색

Added getAll() function in Data

Brendan Abolivier 9 년 전
부모
커밋
cf841f479a
2개의 변경된 파일34개의 추가작업 그리고 11개의 파일을 삭제
  1. 22
    11
      models/data.class.php
  2. 12
    0
      models/promo.class.php

+ 22
- 11
models/data.class.php 파일 보기

@@ -1,8 +1,9 @@
1 1
 <?php
2 2
 
3
-require_once(dirname(__DIR__)."connector.class.php");
3
+require_once(dirname(__DIR__) . "connector.class.php");
4 4
 
5
-class Data {
5
+class Data
6
+{
6 7
     private $identifiant;
7 8
     private $nom_fils;
8 9
     private $prenom_fils;
@@ -12,7 +13,8 @@ class Data {
12 13
     private $date;
13 14
     private $ip;
14 15
 
15
-    function __construct($email) {
16
+    function __construct($email)
17
+    {
16 18
         $bdd = new Connector();
17 19
 
18 20
         $data = $bdd->Select("*", "data", array(
@@ -160,7 +162,8 @@ class Data {
160 162
         $this->ip = $ip;
161 163
     }
162 164
 
163
-    function write() {
165
+    function write()
166
+    {
164 167
         $bdd = new Connector();
165 168
 
166 169
         $data = $bdd->Select("*", "data", array(
@@ -172,8 +175,8 @@ class Data {
172 175
         $attrs = get_object_vars($this);
173 176
         $toUpdate = array();
174 177
 
175
-        foreach($attrs as $key=>$value) {
176
-            if($value != $data[$key]) {
178
+        foreach ($attrs as $key => $value) {
179
+            if ($value != $data[$key]) {
177 180
                 $toUpdate[$key] = $value;
178 181
             }
179 182
         }
@@ -184,7 +187,8 @@ class Data {
184 187
         ));
185 188
     }
186 189
 
187
-    public static function extract() {
190
+    public static function extract()
191
+    {
188 192
         $bdd = new Connector();
189 193
         $data = $bdd->Select("*", "data");
190 194
 
@@ -192,13 +196,13 @@ class Data {
192 196
 
193 197
         // Head line
194 198
         $keys = array();
195
-        foreach($data[0] as $key=>$value) {
199
+        foreach ($data[0] as $key => $value) {
196 200
             array_push($keys, $key);
197 201
         }
198
-        $csv .= implode(",", $keys)."\n";
202
+        $csv .= implode(",", $keys) . "\n";
199 203
 
200 204
         // Content
201
-        foreach($data as $student) {
205
+        foreach ($data as $student) {
202 206
             $csv .= implode(",", $student);
203 207
             $csv .= "\n";
204 208
         }
@@ -206,7 +210,14 @@ class Data {
206 210
         return $csv;
207 211
     }
208 212
 
209
-    function erase() {
213
+    public static function getAll()
214
+    {
215
+        $bdd = new Connector();
216
+        return $bdd->Select("*", "data");
217
+    }
218
+
219
+    function erase()
220
+    {
210 221
         $bdd = new Connector();
211 222
         $bdd->Delete("data", array(array("identifiant", "=", $this->identifiant)));
212 223
     }

+ 12
- 0
models/promo.class.php 파일 보기

@@ -0,0 +1,12 @@
1
+<?
2
+
3
+require_once(dirname(__DIR__)."connector.class.php");
4
+
5
+class Promo {
6
+    private $id_promo;
7
+    private $libelle;
8
+
9
+    function __construct($id) {
10
+
11
+    }
12
+}