Files
liche/common/models/topics/Topic_user_log_model.php
T
2021-08-02 11:44:52 +08:00

60 lines
1.3 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2020/9/16
* Time: 17:47
*/
class Topic_user_log_model extends HD_Model{
private $table_name = 'lc_topic_user_log';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* @param string $map_key
* @param string $map_value
* @param array $where
* @param string $select
* @param $groupby
* @return array
*/
public function map_groupby($map_key = 'id', $map_value = '', $where = array(), $select = '', $groupby){
$map = array();
if($select)
{
$this->db->select($select, false);
}
if($where)
{
$this->db->where($where);
}
$this->db->group_by($groupby);
$list = $this->db->get($this->table_name)->result_array();
if($list)
{
foreach($list as $item)
{
if($map_value)
{
$map[$item[$map_key]] = $item[$map_value] ? $item[$map_value] : $item;
}
else
{
$map[$item[$map_key]][] = $item;
}
}
}
return $map;
}
}