Codeigniter Tutorials
- What is codeigniter?
- Application_Architecture
- MVC Architecture
- HMVC Architecture
- Codeigniter Configuration
- Remove index.php from url in codeigniter
- MVC Concept
- View
- Alternate PHP Syntax for View Files
- Routing
- Codeigniter URL
- Get Current URL
- Previous page URL get
- Seo Friendly URL
- Slug Create in codeigniter
- What is _remap() function
- Remove controller name from url in codeigniter
- Codeigniter Controller Class
- Class Constructor
- GET $ POST method in Codeigniter
- Models
- Basepath, Apppath, FCPATH
- URI Segment
- Page Redirect
- Helper class
- Custom Helper class
- Form Helper
- Common Helper Functions
- Common Function
- Array Problems
- Call controller in Helper
- Add active class to menu using Helper class
- Custom Library
- Custom Library Example
- when to use get_instance()
- Codeigniter Hook
- how to work inline css in codeigniter
- Custom 404 page
- 404 custom error page
- Create custom config file in codeigniter
- How to set and get config item value
- How to Speed Up CodeIgniter App?
- Codeigniter Functions
- Session
- cookies
- How to Set & Get Tempdata in Codeigniter
- flash messages in Codeigniter
- Flashdata
- Encryption and Decryption In CodeIgniter
- Codeigniter security
- csrf token form security
- Password Hashing
- Form Validation
- Custom Validation
- Registration Form with validation
- Server Side Form Validation
- Validate Select Option Field
- Date Format Validation
- Date Format change in codeigniter
- Date Functions
- DOB Validation
- CI CRUD
- User SignUp
- User Login
- User Logout
- Login Account
- Login form with RememberMe
- Login Form with session
- User change password
- Change Password with Callback Validation to Check Old Password
- Forgot password
- Reset password
- Insert data in database
- Fetch data from database
- Update data in database
- Delete data in database
- File Upload
- Image Upload with resize Image
- Upload Multiple file and images
- Upload Multiple images with CRUD
- File and image update
- Upload Image Using Ajax.
- Email Send
- Email Send Using Email library
- Email Send Using SMTP Gmail
- Notification send
- store data in json format in DB
- Json parse
- Fetch data Using Ajax with Json data
- How to Show data Using Ajax with Json parse
- Get JSON Data from PHP Script using jQuery Ajax
- Insert data Using Ajax
- Submit data Using Ajax with form validation
- How to show data Using Ajax in codeigniter
- Insert & Update Using Ajax
- Registration Form With Validation Using Ajax in codeigniter
- Delete data Using Ajax Confirmation
- Delete All data Using checkbox selection
- Ajax CSRF Token
- Ajax Post
- Ajax serverside form validation
- Contact form using AJAX with form validation
- DataTable Using Ajax dynamically
- DataTables pagination using AJAX with Custom filter
- DataTables AJAX Pagination with Search and Sort in codeigniter
- DataTables in Codeigniter using Ajax
- Ajax Custom Serarch
- Ajax Live Data Search using Jquery PHP MySql
- Ajax Custom Serarch and sorting in datatable
- Dynamic Search Using Ajax
- Autocomplete using jquery ajax
- Jquery Ajax Autocomplete Search using Typeahead
- Dynamic Dependent Dropdown Using Ajax
- Dynamic Dependent Dropdown list Using Ajax
- Dynamic Dependent Dropdown in codeigniter using Ajax
- ajax username/email availability check using JQuery
- Check Email Availability Using Ajax
- Data Load on mouse scroll
- Ajax CI Pagination
- Pagination in codeigniter
- Ajax Codeigniter Pagination
- email exists or not using ajax with json
- CRUD using AJAX With Modal popup in CI
- Add / Show Data on modal popup using Ajax
- Modal popup Validation using Ajax
- Data show on Modal popup Using Ajax
- Add / Remove text field dynamically using jquery ajax
- How to Add/Delete Multiple HTML Rows using JavaScript
- Delete Multiple Rows using Checkbox
- Multiple Checkbox value
- Form submit using jquery Example
- REST & SOAP API
- Multi-Language implementation in CodeIgniter
- How to pass multiple array in view
- Captcha
- create zip file and download
- PhpOffice PhpSpreadsheet Library (Export data in excel sheet)
- data export in excel sheet
- Excel File generate in Codeigniter using PHPExcel
- Dompdf library
- tcpdf library
- Html table to Excel & docs download
- CI Database Query
- Database Query
- SQL Injection Prevention
- Auth Model
- Join Mysql
- Tree View in dropdown option list
- OTP Integration in codeigniter
- curl post
- download file using curl
- Sweet Alert
- Sweet alert Delete & Success
- Log Message in Codeigniter
- Menu & Submenu show dynamically
- Set Default value in input box
- Cron Jobs
- Stored Procedure
- Display Loading Image when AJAX call is in Progress
- Send SMS
- IP Address
- Codeigniter Tutorialspoint
- Website Link
- How To Create Dynamic Xml Sitemap In Codeigniter
- Paypal Payment Integration
- Get Latitude and Longitude From Address in Codeigniter Using google map API
- How To Create Simple Bar Chart In Codeigniter Using AmCharts?
- dynamic Highcharts in Codeigniter
- Barcode in Codeigniter
- Codeigniter Interview Questions
- Project
Home » Codeigniter »
Auth Model
File name : Auth_model.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Auth_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
public function politician_info()
{
$this->db->select('*');
$this->db->from('politician_info');
$this->db->order_by("vote_count","desc");
$this->db->where('status', 1);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
function user_insert($data,$leader_id){
$this->db->insert('user_info', $data);
$this->db->select('*');
$this->db->from('politician_info');
$this->db->where('id', $leader_id);
//$query = $this->db->get();
$query = $this->db->get()->row()->vote_count;
//echo $query;
$count = $query;
$upd = $count+1;
echo $upd;
$target_value = 100000;
$pecentage = ($upd / $target_value)*100;
$this->db->set('vote_count',$upd);
$this->db->set('vote_percentage',$pecentage);
$this->db->where('id',$leader_id);
$this->db->update('politician_info');
return;
}
/*
function update_student_id1($id,$data){
$this->db->where('student_id', $id);
$this->db->update('students', $data);
$this->db->where('id', $leader_id);
$this->db->update('politician_info');
}
*/
public function leader_details($id)
{
$this->db->select('*');
$this->db->from('politician_info');
$this->db->where('id',$id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
public function comments_insert($data)
{
$this->db->insert('comments_details', $data);
return;
}
public function getcomments_info($leader_id)
{
$this->db->select('*');
$this->db->from('comments_details');
$this->db->where('leader_id', $leader_id);
$qry = $this->db->get();
if ($qry->num_rows() > 0) {
return $qry->result();
} else {
//return false;
return $qry->result();
}
}
public function member_register($data)
{
$this->db->insert('politician_info', $data);
return;
}
}
Auth_model
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Admin_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
public function get_user($username, $password)
{
$qry = "select * from admin_info where user_id='$username' and password = '$password'";
$result = $this->db->query($qry);
return $result->num_rows();
}
public function politician_info()
{
$this->db->select('*');
$this->db->from('politician_info');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
public function user_info()
{
$this->db->select('*');
$this->db->from('user_info');
$this->db->order_by("uid", "desc");
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
public function admin_info()
{
$this->db->select('*');
$this->db->from('admin_info');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
public function get_admin_info($id)
{
$this->db->select('*');
$this->db->from('admin_info');
$this->db->where('id', $id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
public function admin_update($data)
{
$this->db->set('id',$upd);
$this->db->where('id',$id);
$this->db->update('admin_info');
}
public function upd_admininfo($data,$id)
{
//$this->db->set('id',$upd);
$this->db->where('id',$id);
$this->db->update('admin_info',$data);
}
public function upd_leader_info($data,$id)
{
//$this->db->set('id',$upd);
$this->db->where('id',$id);
$this->db->update('politician_info',$data);
}
public function comments_info()
{
$this->db->select('*');
$this->db->from('comments_details');
$this->db->order_by("cid", "desc");
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
public function leader_insert($data)
{
$this->db->insert('politician_info', $data);
}
public function get_leader_info($id)
{
$this->db->select('*');
$this->db->from('politician_info');
$this->db->where('id', $id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
}
<?php
defined('BASEPATH') OR exit('no direct access allowd');
class Action extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function deltecomments()
{
$id = $this->input->post('id');
if (empty($id))
{
show_404();
}
$this->db->where('cid', $id);
$this->db->delete('comments_details');
$this->session->set_flashdata('message', 'Deleted Sucessfully');
exit;
}
public function delteleader()
{
$id = $this->input->post('id');
$this->db->where('id', $id);
$this->db->delete('politician_info');
return;
}
public function delteuser()
{
$id = $this->input->post('id');
$this->db->where('uid', $id);
$this->db->delete('user_info');
return;
}
public function admindelete()
{
$id = $this->input->post('id');
$this->db->where('id', $id);
$this->db->delete('admin_info');
return;
}
public function datafetchadmin()
{
$id = $this->input->post('id');
$adminsresult = $this->Admin_model->get_admin_info($id);
$data['editmodaldata'] = $adminsresult;
//print_r($data);
$editadmindata_html = $this->load->view('admin_views/editadminmodal',$data,true);
echo $editadmindata_html;
exit;
}
public function updateadmin()
{
$data = array(
'id' => $this->input->post('id'),
'user_id' => $this->input->post('name'),
'password' => $this->input->post('password'),
'email' => $this->input->post('email')
);
$this->Admin_model->admin_update($data);
}
public function edadmininfo()
{
$aid = $this->uri->segment(4);
$adminsresult = $this->Admin_model->get_admin_info($aid);
$data['editmodaldata'] = $adminsresult;
//print_r($data);
$this->load->view('admin_views/header');
$this->load->view('admin_views/leftpanel');
$this->load->view('admin_views/editadminview',$data);
$this->load->view('admin_views/footer');
}
public function update_admin_info()
{
$id = $this->input->post('id');
$data = array(
'user_id' => $this->input->post('uid'),
'password' => $this->input->post('password'),
'email' => $this->input->post('email')
);
$this->Admin_model->upd_admininfo($data,$id);
$this->session->set_flashdata('msg', '<div class="alert alert-danger text-center">Your data is successfully submited.</div>');
redirect('admin/Admininfo');
}
public function acceptmember()
{
$id = $this->input->post('id');
$this->db->set('status',1);
$this->db->where('id',$id);
$this->db->update('politician_info');
}
}
Admin_model (Rahat)
<?php
defined('BASEPATH') OR exit('no direct script access allowed');
class Admin_basic_model extends CI_Model
{
public function get_user_info($user_id)
{
$this->db->select('*');
$this->db->from('basic_plan');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
return $query->result();
}
public function user_validate($data)
{
$this->db->select('*');
$this->db->from('user_register');
//$this->db->from('admin_info');
$this->db->where('user_id',$data['user_name']);
$this->db->where('password',$data['password']);
$query=$this->db->get();
return $query->result();
}
public function get_active_members()
{
$this->db->select('*');
$this->db->from('basic_plan');
$this->db->where('status', 1);
$query=$this->db->get();
return $query->result();
}
public function get_inactive_members()
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('status', 0);
$query=$this->db->get();
return $query->result();
}
public function get_all_members()
{
$this->db->select('*');
$this->db->from('user_register');
$query=$this->db->get();
return $query->result();
}
public function get_downusers($user_id)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('sponser_code',$user_id);
$query=$this->db->get();
return $query->result();
}
public function get_all_receiptmembers()
{
$this->db->select('*');
$this->db->from('basic_plan');
$query=$this->db->get();
return $query->result();
}
public function add_money($data)
{
$this->db->insert('wallet_money',$data);
if($this->db->affected_rows() > 0)
{
return true;
}
else
{
return false;
}
}
public function get_walletdetails()
{
$this->db->select('*');
$this->db->from('wallet_money');
$query=$this->db->get();
return $query->result();
}
public function get_withdrawal_request()
{
$this->db->select('*');
$this->db->from('wallet_money');
$this->db->where('type','dr');
$query=$this->db->get();
return $query->result();
}
public function get_admin_profile($admin_user_id)
{
$this->db->select('*');
$this->db->from('user_register');
//$this->db->from('admin_info');
$this->db->where('user_id',$admin_user_id);
$query=$this->db->get();
return $query->result();
}
public function get_leveltwo_user()
{
$this->db->select('*');
$this->db->from('basic_auto_pool_level');
$this->db->where('user_level',2);
$this->db->order_by('created_at','asc');
$query=$this->db->get();
return $query->result();
}
public function get_autocount_renwal($user_id,$id)
{
$this->db->select('*');
$this->db->from('basic_auto_pool_level');
$this->db->where('id',$id);
$this->db->where('user_id',$user_id);
$this->db->order_by('created_at','asc');
$query=$this->db->get();
//return $query->result();
$result = $query->row();
if(!empty($result))
{
//return $result->autorenewal_count;
return $result;
}else{
return '';
}
}
public function user_id_get($id)
{
$this->db->select('user_id');
$this->db->from('pay_slip');
$this->db->where('id',$id);
$query=$this->db->get();
//return $query->result();
$result = $query->row();
if(!empty($result))
{
return $result->user_id;
}else{
return '';
}
}
public function user_plantype_get($id)
{
$this->db->select('plan_type');
$this->db->from('pay_slip');
$this->db->where('id',$id);
$query=$this->db->get();
//return $query->result();
$result = $query->row();
if(!empty($result))
{
return $result->plan_type;
}else{
return '';
}
}
public function get_userinfo_planb($user_id)
{
$this->db->select('user_id,name,sponser_code,sponser_name,plan_b');
$this->db->from('user_register');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
//return $query->result();
return $result = $query->row();
}
public function add_gallery_image($dataarray)
{
$this->db->insert('gallery',$dataarray);
if($this->db->affected_rows() > 0)
{
return true;
}
else
{
return false;
}
}
public function gallery_info()
{
$this->db->select('*');
$this->db->from('gallery');
$query=$this->db->get();
return $query->result();
}
public function get_one_leveruser()
{
$result = array();
$this->db->select('user_id');
$this->db->from('basic_auto_pool_level');
$this->db->where('user_level',1);
$this->db->order_by('created_at','asc');
$query=$this->db->get();
$result = $query->row();
if(!empty($result))
{
return $result->user_id;
}else{
return '';
}
}
public function useridget($id='')
{
$this->db->select('user_id');
$this->db->from('basic_plan');
$this->db->where('id',$id);
$query=$this->db->get();
//return $query->result();
$result = $query->row();
if(!empty($result))
{
return $result->user_id;
}else{
return '';
}
}
}
User_model (Rahat)
<?php
defined('BASEPATH') OR exit('no direct script access allowed');
class Basic_model extends CI_Model
{
public function get_basic_plan()
{
$this->db->select('*');
$this->db->from('plan');
$this->db->where('plan_type','B-1000');
$query=$this->db->get();
return $query->result();
}
public function user_validate($data)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('user_id',$data['user_name']);
$this->db->where('password',$data['user_password']);
$query=$this->db->get();
return $query->result();
}
public function check_mobileno($mobileno)
{
$this->db->select('mobile');
$this->db->from('user_register');
$this->db->where('mobile',$mobileno);
$query=$this->db->get();
$result = $query->row();
if($result)
{
return $result->mobile;
}
else
{
return false;
}
}
public function check_user_exits_not($user_id)
{
$this->db->select('user_id');
$this->db->from('basic_plan');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
$result = $query->row();
if($result)
{
return $result->user_id;
}
else
{
return false;
}
}
public function get_zero_leveruser()
{
$result = array();
$this->db->select('user_id');
$this->db->from('basic_auto_pool_level');
$this->db->where('user_level',0);
$this->db->order_by('created_at','asc');
$query=$this->db->get();
$result = $query->row();
if(!empty($result))
{
return $result->user_id;
}else{
return '';
}
}
public function get_one_leveruser()
{
$result = array();
$this->db->select('user_id');
$this->db->from('basic_auto_pool_level');
$this->db->where('user_level',1);
$this->db->order_by('created_at','asc');
$query=$this->db->get();
$result = $query->row();
if(!empty($result))
{
return $result->user_id;
}else{
return '';
}
}
public function get_levelone_child($pid)
{
$this->db->select('upu.user_id');
$this->db->from('basic_auto_pool_user as upu');
$this->db->join('basic_auto_pool_level apl', 'apl.user_id = upu.user_id', 'inner');
$this->db->where('upu.parent_id',$pid);
$this->db->where('apl.user_level',0);
$this->db->order_by('upu.created_at','ASC');
$query=$this->db->get();
$result = $query->row();
if($result)
{
return $result->user_id;
}else{
return '';
}
}
public function get_sponserinfo($sp_id)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('user_id',$sp_id);
$query=$this->db->get();
return $query->result();
}
public function user_details($user_sponser_code='')
{
$this->db->select('*');
$this->db->from('basic_plan');
$this->db->where('user_id',$user_sponser_code);
$query=$this->db->get();
return $query->result();
}
public function get_father_code($useruid)
{
$this->db->select('*');
$this->db->from('auto_pool');
$this->db->where('user_id',$useruid);
$query=$this->db->get();
return $query->result();
}
public function gf_code($spcode)
{
$this->db->select('*');
$this->db->from('auto_pool');
$this->db->where('user_id',$spcode);
$query=$this->db->get();
return $query->result();
}
public function get_user_child_pool($user_sponser_code)
{
$this->db->select('*');
$this->db->from('auto_pool');
$this->db->where('user_id',$user_sponser_code);
$query=$this->db->get();
return $query->result();
}
public function get_user_child_leftposition($gf_id)
{
$this->db->select('*');
$this->db->from('auto_pool');
$this->db->where('sponser_code',$gf_id);
$this->db->where('user_position','left');
$query=$this->db->get();
//$query = SELECT * FROM 'auto_pool' WHERE sponser_code='up-1001' and user_position='left';
return $query->result();
}
public function get_user_child_middleposition($gf_id)
{
$this->db->select('*');
$this->db->from('auto_pool');
$this->db->where('sponser_code',$gf_id);
$this->db->where('user_position','middle');
$query=$this->db->get();
return $query->result();
}
public function get_user_child_rightposition($gf_id)
{
$this->db->select('*');
$this->db->from('auto_pool');
$this->db->where('sponser_code',$gf_id);
$this->db->where('user_position','right');
$query=$this->db->get();
return $query->result();
}
public function get_left_child($user_sponser_code){
$this->db->select('*');
$this->db->from('user_register');
$this->db->where("sponser_code", $user_sponser_code);
$this->db->where("user_position", "left");
$query=$this->db->get();
return $query->result();
}
public function get_user_child_all($last_uid_sponser_code)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where("sponser_code", $last_uid_sponser_code);
$query=$this->db->get();
return $query->result();
}
public function member_register($dataarray)
{
$this->db->insert('basic_plan', $dataarray);
if ($this->db->affected_rows() > 0) {
return true;
} else {
return false;
}
}
public function get_sponser_details_move($user_sponser_code)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('user_id',$user_sponser_code);
$query=$this->db->get();
return $query->result();
}
public function addin_autopool($auto_pool_user)
{
$this->db->insert('auto_pool',$auto_pool_user);
if ($this->db->affected_rows() > 0) {
return true;
} else {
return false;
}
}
public function add_auto_pool_user($datainfo)
{
$this->db->insert('basic_auto_pool_user',$datainfo);
if ($this->db->affected_rows() > 0) {
return true;
} else {
return false;
}
}
public function add_auto_pool_level($data_userlevel)
{
$this->db->insert('basic_auto_pool_level',$data_userlevel);
if ($this->db->affected_rows() > 0) {
return true;
} else {
return false;
}
}
public function add_auto_pool_position($datainfo)
{
$this->db->insert('auto_pool_position',$datainfo);
if ($this->db->affected_rows() > 0) {
return true;
} else {
return false;
}
}
/* ############################### For User panel ############### */
public function getuserinfo($user_id)
{
$this->db->select('mobile');
$this->db->from('user_register');
$this->db->where('user_id',$user_id);
$query = $this->db->get();
$result= $query->row();
if($result)
{
return $result->mobile;
}
else
{
return false;
}
}
public function login_user($uid, $pass)
{
$result = array();
$this->db->select('*');
$this->db->from('user_register');
// $multicol = array('sponser_id' => $uid, 'mobile' => $uid);
//$this->db->where($multicol);
$this->db->where('user_id',$uid);
$this->db->where('password',$pass);
//$this -> db -> where('IsActive',1);
$query = $this->db->get();
if($query->num_rows() > 0 )
{
return $query->result();
}
else
{
return false;
}
}
public function get_userdetails($user_id)
{
$this->db->select('*');
$this->db->from('basic_plan');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
return $query->result();
}
public function get_usermember($user_id)
{
$this->db->select('*');
$this->db->from('basic_plan');
$this->db->where('sponser_code',$user_id);
$query=$this->db->get();
return $query->result();
}
public function get_inactivemembers($user_id)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('sponser_code',$user_id);
$query=$this->db->get();
return $query->result();
}
public function get_downusers($user_id)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('sponser_code',$user_id);
$query=$this->db->get();
return $query->result();
}
public function upload_receipt_image($data)
{
$this->db->insert('pay_slip', $data);
if($this->db->affected_rows() > 0)
{
return true;
}
else
{
return false;
}
}
public function get_user_receipt($user_id)
{
$this->db->select('*');
$this->db->from('basic_plan');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
return $query->result();
}
public function get_user_wallet_info($user_id)
{
$this->db->select('*');
$this->db->from('wallet_money');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
return $query->result();
}
public function get_user_money_withdrawal($user_id)
{
$this->db->select('*');
$this->db->from('wallet_money');
$this->db->where('user_id',$user_id);
$this->db->where('type','dr');
$query=$this->db->get();
return $query->result();
}
public function get_user_profile($user_id)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
return $query->result();
}
public function match_password($user_id,$oldpassword)
{
$this->db->select('password');
$this->db->from('user_register');
$this->db->where('user_id',$user_id);
$this->db->where('password',$oldpassword);
$query=$this->db->get();
return $query->result();
}
public function get_autopool_usersinfo($user_id)
{
$this->db->select('*');
$this->db->from('basic_auto_pool_level');
$this->db->where('user_id',$user_id);
$query=$this->db->get();
return $query->result();
}
public function get_autopool_childuser($user_id)
{
$this->db->select('*');
$this->db->from('auto_pool_user');
$this->db->where('parent_id',$user_id);
$query=$this->db->get();
return $query->result();
}
public function check_levelone($user_id)
{
$this->db->select('*');
$this->db->from('user_register');
$this->db->where('user_id',$user_id);
$this->db->where('user_level',1);
$query=$this->db->get();
return $query->result();
}
public function add_user_planb($data)
{
$this->db->insert('pay_slip', $data);
$this->db->insert('pay_slip', $data);
if($this->db->affected_rows() > 0)
{
return true;
}
else
{
return false;
}
}
public function get_plan()
{
$this->db->select('*');
$this->db->from('plan');
//$this->db->order_by('id','desc');
$this->db->limit(1,1);
$query=$this->db->get();
return $query->result();
}
public function getamount($plan_type)
{
$this->db->select('plan_amount');
$this->db->from('plan');
$this->db->where('plan_type',$plan_type);
$query=$this->db->get();
//return $query->result();
/*if($result)
{
return $result->plan_amount;
}else{
return '';
}*/
return $result = $query->row();
}
public function get_planbasic()
{
$this->db->select('*');
$this->db->from('plan');
//$this->db->order_by('id','desc');
$this->db->limit(3);
$query=$this->db->get();
return $query->result();
}
public function getamount_basic($plan_type)
{
$this->db->select('plan_amount');
$this->db->from('plan');
$this->db->where('plan_type',$plan_type);
$query=$this->db->get();
//return $query->result();
$result = $query->row();
if($result)
{
return $result->plan_amount;
}else{
return '';
}
//return $result = $query->row();
}
public function contact_us($data)
{
$this->db->insert('contactus', $data);
if($this->db->affected_rows() > 0)
{
return true;
}
else
{
return false;
}
}
public function get_plandetails()
{
$this->db->select('*');
$this->db->from('plan');
$query=$this->db->get();
return $query->result();
}
public function get_plantype($id)
{
$this->db->select('*');
$this->db->from('plan');
$this->db->where('id',$id);
$query=$this->db->get();
return $query->result();
}
// #################################################################################
}
Crud Operation :- Save, Update, Delete Operations
<?php
class Product_model extends CI_Model{
function product_list(){
$hasil=$this->db->get('product');
return $hasil->result();
}
function save_product(){
$data = array(
'product_code' => $this->input->post('product_code'),
'product_name' => $this->input->post('product_name'),
'product_price' => $this->input->post('price'),
);
$result=$this->db->insert('product',$data);
return $result;
}
function update_product(){
$product_code=$this->input->post('product_code');
$product_name=$this->input->post('product_name');
$product_price=$this->input->post('price');
$this->db->set('product_name', $product_name);
$this->db->set('product_price', $product_price);
$this->db->where('product_code', $product_code);
$result=$this->db->update('product');
return $result;
}
function delete_product(){
$product_code=$this->input->post('product_code');
$this->db->where('product_code', $product_code);
$result=$this->db->delete('product');
return $result;
}
}