CI-SQL

Send Snippet To: Save this snippet to Code Collector Pro -- view all graywood's snippets
language: Other
license: Other

Code for Snippet:

                
CI - SQL 
 
 
/* delete */
 
               $this->db->where('idx',$data["idx"]);
               $this->db->delete('intranet_member');
 
               if($this->db->trans_status() == false){
                    $this->db->trans_rollback();
               }else{
                    $this->db->trans_commit();
               }
 
/* insert */
$this->db->set(array(
                    'company' => $data["inputCompany"],
                    'regdate' => date("Y-m-d"),
                    'worker_name' => $data["worker_name"],
                    'use_yn' => 'N'
                    ));  
$this->db->insert('tbd_intranet_work');
 
 
/*select list */
              $this->db->where(array('isActive' => 'Y'));
              $this->db->order_by('idx','asc');
              $query=$this->db->get('tbd_intranet_work_worker');
               return $query->result();     
 
/* select */
               $this->db->where('goodsIDX', $data->goodsIDX);
               $query=$this->db->get('intranet_guest');
               return $query->row();
 
/* edit */
                    $db_data = array(
                    'company' => $data["company"],
                    'memo' => $data["memo"]
               );
 
          $this->db->where('idx',$data["idx"]);
          $this->db->update('tbd_intranet_work', $db_data);
 
                    if($this->db->trans_status() == false){
                              $this->db->trans_rollback();
                    }else{
                              $this->db->trans_commit();
                    }
 
 
 
function getTotalCount($data) {
        // Like  ??? ??
        if ($data["sv"] != "" || strlen($data["sv"]) != 0) {
            $this->db->like($data["sk"], $data["sv"]);
        }
 
        $this->db->from('tb_member');
        return $this->db->count_all_results();
    }
 
/* ??? ?? */
function getUserIDCount($userID) {    
	return $this->db->query("select count(idx) as idCount  from tb_member where  userID =  '".$userID."'  ")->row(); 
}
 
	$query = "";
	return $this->db->query($query)->result();
 
 
$query = "update tb_insure set insureStatus = '".$data["ch_status"]."' where idx in ('".$data["checkedValue"]."') ";
          $this->db->query($query);
 
 
/* ????? */
$mySessionID = $this->session->userdata('mySessionID');
        if ($mySessionID == FALSE || $mySessionID == "") {
            $mySessionID = $this->session->userdata('session_id');
            $this->session->set_userdata('mySessionID', $mySessionID);
        }
 
 
$data["session_id"] = $mySessionID;
 
 
/* ?? ?? */
class Cookie_hlp extends CI_Controller {
    function __construct()
    {
        parent::__construct();
 
        // Cookie Helper Load
        $this->load->helper('cookie');
        // Url Helper Load
        $this->load->helper('url');
    }
 
    function index() {
        $data['cookie'] = get_cookie('test'); // $this->input->cookie('userID', TRUE);
        $this->load->view('cookie_hlp_sample', $data);
    }
 
    function set() {
        set_cookie('test', $this->input->post('user_data'), 3600);
        redirect('/cookie_hlp');
    }
 
    function del() {
        delete_cookie('test');
        redirect('/cookie_hlp');
    }
}
 
 
/* ?? ?? */
        $this->load->library('user_agent');
        if ($this->agent->is_referral())
        {
            $data["rURL"] = $this->agent->referrer();
        }
 
 
 
/* ?? ?? ?? */
$userID = $this->input->cookie('userID', TRUE);
        if (strlen(trim($userID)) != 0) {
             redirect('/', 'refresh');
        }
 
 
/* ??? ?? */
$go["msg"] = "???? ?? ??? ????.";
$go["goURL"] = "/";
$this->load->view('go', $go);
 
 
$go["msg"] = "???? ??? ??????.";
$go["goURL"] = "/main/login?rURL=/".$this->uri->uri_string();
$this->load->view('go', $go);
 
1. ?? ?/? ??: 
$this->db->where('name', $name);
 
// ????: WHERE name = 'Joe'
??(=) ??? ???? ??????.
 
? ??? ??? ???? ?? AND ? ?????.:
 
$this->db->where('name', $name);
$this->db->where('title', $title);
$this->db->where('status', $status);
 
// WHERE name ='Joe' AND title = 'boss' AND status = 'active'
2. ??? ?/? ??:
??? ????? ????? ???? ??? ??? ??? ????:
 
$this->db->where('name !=', $name);
$this->db->where('id <', $id);
 
// ????: WHERE name != 'Joe' AND id < 45
3. 
1. ???? ??: 
$array = array('name' => $name, 'title' => $title, 'status' => $status);
 
$this->db->where($array);
 
// ????: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
??? ?? ?? ????? ??? ?? ????.:
 
$array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);
 
$this->db->where($array);
2. ??? ??? ??:
??? ?? Where ?? ?? ??? ? ? ????:
 
$where = "name='Joe' AND status='boss' OR status='active'";
 
$this->db->where($where);
 
 
????
????
$session_id = $this->session->userdata('session_id');
????
$newdata = array(    'userIsLogin'  => 'OK',    'userEmail'     => $data["userEmail"],    'isUserLogin' => true);$this->session->set_userdata($newdata);
 
 
 
?????? ?? Removing Session Data
 
set_userdata() ??? ???? ??? ?? ?????? , unset_userdata() ? ???? ?????? ???? ?? ???. ????, 'some_name' ? ???? ???????:
 
$this->session->unset_userdata('some_name');
 
???? ????? ?? ???? ?????? ??? ?? ????? ???? ???? ????.
 
 
$array_items = array('username' => '', 'email' => '');
 
$this->session->unset_userdata($array_items);
 
??? ??? ????
$this->session->set_userdata('some_name', 'some_value');
 
 
** ??? ??? : [email protected] **
 
 
 
// ????? ???? ???$dataHeader["isUserLogin"] = $this->session->userdata('isUserLogin');$data["isUserLogin"] = $this->session->userdata('isUserLogin');$data["userIsLogin"] = $this->session->userdata('userIsLogin');$dataHeader["userIsLogin"] = $this->session->userdata('userIsLogin');
if ($data["userIsLogin"] != "OK") {    redirect("/", "refresh");}
 
// ???? ?? ?? ???? ???$userLoginEmail = $this->session->userdata('userEmail');if (!($userLoginEmail == "[email protected]" || $userLoginEmail == "[email protected]")) {    $go["msg"] = "???? ?? ??? ?????.";    $go["goURL"] = "/";    $this->load->view('go', $go);    exit();}
 
 
 
 
 
 
 
 
comments powered by Disqus

Info

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 11
Date Added: 2017-06-25 06:31:11
Last Modified: 2017-12-28 02:05:50

Web Analytics