<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Users_model extends CI_Model
{

    function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    // public function getAllUsers()
    // {
    //     $query = $this->db->get('users');
    //     return $query->result();
    // }

    // public function insert($user)
    // {
    //     $this->db->insert('users', $user);
    //     return $this->db->insert_id();
    // }

    // public function getUser($id)
    // {
    //     $query = $this->db->get_where('users', array('id' => $id));
    //     return $query->row_array();
    // }

    // public function activate($data, $id)
    // {
    //     $this->db->where('users.id', $id);
    //     return $this->db->update('users', $data);
    // }

    // function validate($email, $password)
    // {
    //     $this->db->where('email', $email);
    //     $this->db->where('password', $password);
    //     $result = $this->db->get('users', 1);
    //     // print_r($result);
    //     return $result;
    // }

    public function getAllUsers()
    {
        $sql = "SELECT vc.id, hd.type,hd.head_title,vc.title,vc.description,vc.video_poster,vc.adult_logo,vc.video_name,vc.created_at FROM headers AS hd
        INNER JOIN video_contant as vc ON hd.id = vc.hid;";
        return $this->db->query($sql)->result_array();
    }

    public function activate($data, $id)
    {
        $this->db->where('video_contant.id', $id);
        return $this->db->update('video_contant', $data);
    }
}
