chess/application/models/Get_model.php

181 lines
4.3 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Get_model extends CI_Model {
public function __construct(){
parent::__construct();
}
public function get_table($table)
{
return $this->db->select('*')
->from($table)
->get()->result_array();
}
public function getDataById_wallet($tbl,$where)
{
$this->db->select('*');
$this->db->from($tbl);
$this->db->where($where);
$this->db->order_by('t_id', 'desc');
$this->db->limit(1);
$query = $this->db->get();
return $query->row_array();
}
public function get_wallet_history($id){
$this->db->select('*');
$this->db->from('wallet_transaction_details w');
//$this->db->join('tbl_user u', 'w.user_id = u.user_id', 'left');
$this->db->where('w.user_id', $id);
$this->db->order_by('w.t_id','DESC');
$query = $this->db->get();
return $query->result_array();
}
public function rows_count($table, $where){
$this->db->where($where);
$result = $this->db->get($table)->num_rows();
return $result;
}
public function get_by_id($table, $where)
{
$this->db->from($table);
$this->db->where($where);
$query = $this->db->get();
return $query->row_array();
}
public function get_count($table, $where)
{
$this->db->from($table);
$this->db->where($where);
$query = $this->db->get();
return $query->num_rows();
}
public function count_rows($tbl, $where) {
$this->db->select('COUNT(*) as count');
$this->db->from($tbl);
$this->db->where($where);
$this->db->order_by($where,'DESC');
$query = $this->db->get();
$result = $query->row();
return $result->count;
}
public function get_by_id_all($table, $where)
{
$this->db->from($table);
$this->db->where($where);
$query = $this->db->get();
return $query->result();
}
public function num_row($table){
$this->db->select('count(*) as allcount');
$this->db->from($table);
$query = $this->db->get();
$result = $query->result_array();
return $result[0]['allcount'];
}
public function num_row_wh($table, $where){
$this->db->select('count(*) as allcount');
$this->db->from($table);
$this->db->where($where);
$query = $this->db->get();
$result = $query->result_array();
return $result[0]['allcount'];
}
public function list($limit,$offset, $table){
$this->db->limit($limit,$offset);
$this->db->select('*');
$this->db->from($table);
//$this->db->order_by('insale_master.created_at','DESC');
return $this->db->get()->result_array();
}
public function list_by_desc($limit,$offset, $table, $column){
$this->db->limit($limit,$offset);
$this->db->order_by($column,'DESC');
$this->db->select('*');
$this->db->from($table);
//$this->db->order_by('insale_master.created_at','DESC');
$query = $this->db->get();
return $query->result_array();
}
public function list_by_desc_wh($limit,$offset, $table, $column, $where){
$this->db->limit($limit,$offset);
$this->db->order_by($column,'DESC');
$this->db->select('*');
$this->db->from($table);
$this->db->where($where);
//$this->db->order_by('insale_master.created_at','DESC');
return $this->db->get()->result_array();
}
public function get_all($table, $where)
{
$this->db->from($table);
$this->db->where($where);
$query = $this->db->get();
return $query->result_array();
}
public function get_all1($table, $where)
{
$this->db->select('tbl_game_data.player1_id','tbl_user.name' );
$this->db->distinct();
$this->db->from('tbl_game_data');
$this->db->where($where);
$this->db->order_by('tbl_game_data.player1_id','tbl_user.name','DESC');
$query = $this->db->get();
return $query->result_array();
}
public function get_all_desc($table, $column)
{
$this->db->from($table);
// $this->db->where($where);
$this->db->order_by($column,'DESC');
$query = $this->db->get();
return $query->result_array();
}
public function row_getById($table, $where)
{
$this->db->from($table);
$this->db->where($where);
$query = $this->db->get();
return $query->row();
}
}