Browse Source

Optimize user list

Léo Serre 11 months ago
parent
commit
250aff13e5
3 changed files with 6 additions and 12 deletions
  1. 0
    7
      controllers/d.users.php
  2. 5
    4
      models/d.users.php
  3. 1
    1
      views/d.user.member_list.html

+ 0
- 7
controllers/d.users.php View File

@@ -205,13 +205,6 @@ if(isset($controller->splitted_url[1])) {
205 205
 
206 206
 				$users->list_users($page*$rows_per_pages,$rows_per_pages,$orderby,$order);
207 207
 
208
-				$i = 0;
209
-				foreach ($users->ids as $row) {
210
-					$user_list[$i] = new User();
211
-					$user_list[$i]->checkID($row);
212
-					$i++;
213
-				}
214
-
215 208
 				$first = $page*$rows_per_pages+1;
216 209
 				$last = (($page+1)*$rows_per_pages > $users->number ? $users->number : ($page+1)*$rows_per_pages);
217 210
 				

+ 5
- 4
models/d.users.php View File

@@ -383,7 +383,7 @@ function randomPassword() {
383 383
 
384 384
 class Users
385 385
 {
386
-	public $ids = array();
386
+	public $objs = array();
387 387
 	public $number = NULL;
388 388
 
389 389
 	/*****
@@ -421,9 +421,9 @@ class Users
421 421
 		$orderbysafe=$orders[$key];
422 422
 
423 423
 		if ($order == 'ASC')
424
-			$query = "SELECT id FROM users ORDER BY $orderbysafe ASC LIMIT $1 OFFSET $2";
424
+			$query = "SELECT * FROM users ORDER BY $orderbysafe ASC LIMIT $1 OFFSET $2";
425 425
 		else
426
-			$query = "SELECT id FROM users ORDER BY $orderbysafe DESC LIMIT $1 OFFSET $2";
426
+			$query = "SELECT * FROM users ORDER BY $orderbysafe DESC LIMIT $1 OFFSET $2";
427 427
 		
428 428
 
429 429
 		pg_prepare($con, "prepare1", $query) 
@@ -435,7 +435,8 @@ class Users
435 435
 
436 436
 		for($i = 0; $i < pg_num_rows($result); $i++) {
437 437
 			$row = pg_fetch_assoc($result, $i);
438
-			$this->ids[$i] = $row['id'];
438
+			$this->objs[$i] = new User;
439
+			$this->objs[$i]->populate($row);
439 440
 		}
440 441
 	}
441 442
 }

+ 1
- 1
views/d.user.member_list.html View File

@@ -34,7 +34,7 @@
34 34
 						<?=$orderby=='website'?$order=='ASC'?'<i class="fas fa-caret-down" aria-hidden="true"></i>':'<i class="fas fa-caret-up" aria-hidden="true"></i>':''?>
35 35
 					</th>
36 36
 				</tr>
37
-			<? foreach ($user_list as $row) { ?>
37
+			<? foreach ($users->objs as $row) { ?>
38 38
 				<tr>
39 39
 					<td>
40 40
 						<? if ($row->is_avatar_present=='t') { ?>

Loading…
Cancel
Save