Monday 30 January 2017

dbemp

<?php
class dbemp extends CI_model
{
function insert($y)
{
$this->db->insert('registration', $y);
}
    public function check_username_availablity()
    {
        $username = trim($this->input->post('username'));
        $username = strtolower($username);

        $query = $this->db->query("SELECT * FROM registration WHERE username='$username'");
        if($query->num_rows() > 0)
            return false;
        else
            return true;
    }
 

    function getcount()
    {
        return $this->db->count_all('registration');
    }

    function get_all_classes($eid)
    {

        $this->db->where('id',$eid);

        $query = $this->db->get('registration');

        if($query->result())
        {
            $result = $query->result();

            foreach($result as $row)
            {
                $options[$row->id] = $row->username;
            }  
            return $options;
        }
    }
   
function getalldata($offset,$start)
{
$sql="select * from registration where id LIMIT ".$start.",".$offset." ";
$res=$this->db->query($sql);
return $res->result();
}
   
    function getsearch()
    {
        $match=$this->input->post('search');
       
        $res=$this->db->query("select * from registration where(username like'%".$match."%')");
        return $res->result();
    }
    /*
    function getdelete($id)
    {
        $sql="Select *from registration where id='".$id."'";
        $res=$this->db->query($sql);
        return $res->row();
    }*/

      function getAll()
      {
        $query=$this->db->query("SELECT * FROM registration");

         return $query->result();
        //returns from this string in the db, converts it into an array
      }



    function deleteimg($id)
    {
        $sql=$this->db->query("select * from registration where id='".$id."'");
        return $sql->row();
    }
    function delete($id)
    {
        $this->db->where('id',$id);
        $this->db->delete('registration');
    }

    function delete_all($id)
    {
        $this->db->where('id',$id);
        $this->db->delete('registration');
    }

}
?>

No comments:

Post a Comment