<?php
class folder_model extends CI_Model {
 public function add_folder($data){
	$this->db->insert('folders', $data);
 }
 public function get_folder_bypid($pid,$uid){
	$this->db->where("parent",$pid);
	$this->db->where("userid",$uid);
	$result = $this->db->get('folders');
        return $result->result();
 }
 public function get_folder_byuid($uid,$usefor){
		$this->db->where("userid",$uid);
		$this->db->where("usefor",$usefor);
		$this->db->where("parent","root");
	$result = $this->db->get('folders');
        return $result->result();
 }
 public function get_parent($id){
  $this->db->where("id",$id);
  $result = $this->db->get('folders');
   $result = $result->result();
   return $result[0]->parent;
 }
 public function get_delete_folder($id){
  $this->db->where('id', $id);
  $this->db->or_where('parent', $id);
  $result = $this->db->get('folders');
 return  $result->result();
 }
 public function delete_folder($id){
  $this->db->where('id', $id);
  $this->db->or_where('parent', $id);
  $this->db->delete('folders');
  
 }
 public function rename_folder($id,$value){
  $this->db->where('id', $id);
$this->db->update('folders', array("name"=>$value));
 }
}
?>