Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/application/models/ContactModel.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2019-01-04 18:46:10 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ContactModel extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function getContactMessages()
{
$results = $this->db->query('SELECT * FROM contact_messages ORDER BY isUnread DESC')->result_array();
$results = $this->mergeUserName($results);
return $results;
}
private function mergeUserName($results)
{
foreach ($results as $i => $result) {
$result['username'] = null;
$result['displayname'] = null;
if ($result['userID'] == null)
goto next;
$user = $this->db->query('SELECT displayname, username FROM users WHERE ID = ?', [$result['userID']])->result_array();
if (empty($user)) {
$result['userID'] = null;
goto next;
}
$user = $user[0];
$result['username'] = $user['username'];
$result['displayname'] = $user['displayname'];
next: $results[$i] = $result;
}
return $results;
}
}