Welcome Guest, Not a member yet? Register   Sign In
HMVC
#6

[eluser][email protected][/eluser]
Hi

Here is a model code as requested

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mdl_uers extends CI_Model {

function __construct()
{
parent::__construct();
}

function get_table() {
$table = "users";
return $table;
}

function password_check($username, $password){
$table = $this->get_table();
$this->db->where('username', $username);
$this->db->where('password', $password);
$query=$this->db->get($table);
$num_rows = $query->num_rows();

if($num_rows>0){
return TRUE;
}else{
return FALSE;
}
}
function get($order_by){
$table = $this->get_table();
$this->db->order_by($order_by);
$query=$this->db->get($table);
return $query;
}

function get_with_limit($limit, $offset, $order_by) {
$table = $this->get_table();
$this->db->limit($limit, $offset);
$this->db->order_by($order_by);
$query=$this->db->get($table);
return $query;
}

function get_where($id){
$table = $this->get_table();
$this->db->where('id', $id);
$query=$this->db->get($table);
return $query;
}

function get_where_custom($col, $value) {
$table = $this->get_table();
$this->db->where($col, $value);
$query=$this->db->get($table);
return $query;
}

function _insert($data){
$table = $this->get_table();
$this->db->insert($table, $data);
}

function _update($id, $data){
$table = $this->get_table();
$this->db->where('id', $id);
$this->db->update($table, $data);
}

function _delete($id){
$table = $this->get_table();
$this->db->where('id', $id);
$this->db->delete($table);
}

function count_where($column, $value) {
$table = $this->get_table();
$this->db->where($column, $value);
$query=$this->db->get($table);
$num_rows = $query->num_rows();
return $num_rows;
}

function count_all() {
$table = $this->get_table();
$query=$this->db->get($table);
$num_rows = $query->num_rows();
return $num_rows;
}

function get_max() {
$table = $this->get_table();
$this->db->select_max('id');
$query = $this->db->get($table);
$row=$query->row();
$id=$row->id;
return $id;
}

function _custom_query($mysql_query) {
$query = $this->db->query($mysql_query);
return $query;
}
}




Messages In This Thread
HMVC - by El Forum - 07-23-2014, 12:15 AM
HMVC - by El Forum - 07-23-2014, 12:47 AM
HMVC - by El Forum - 07-23-2014, 04:39 AM
HMVC - by El Forum - 07-23-2014, 05:02 AM
HMVC - by El Forum - 07-23-2014, 05:43 AM
HMVC - by El Forum - 07-24-2014, 12:26 AM
HMVC - by El Forum - 07-24-2014, 04:57 AM
HMVC - by El Forum - 07-28-2014, 01:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB