Skip to content

Instantly share code, notes, and snippets.

@scoutman57
Created April 14, 2015 06:14
Show Gist options
  • Save scoutman57/8482db8730c64c5c883f to your computer and use it in GitHub Desktop.
Save scoutman57/8482db8730c64c5c883f to your computer and use it in GitHub Desktop.
<?php
/**
* Description of category_model
*
* @author jk
*/
class Index_Model extends Model {
public function __construct() {
parent::__construct();
}
public function GetIvPrivilegeMembers()
{
/*$members = $this->db->select("SELECT * FROM register WHERE reg_status = 1 LIMIT 0 , 4");
return $members;*/
$limit = '4';
$blockedList = $this->getBlockedList();
if(!empty ($blockedList)) {
$blockedList = "AND reg_bd_id NOT IN ($blockedList)";
}
$members = $this->db->select("SELECT * FROM register WHERE reg_status = 1
AND (reg_privilege_type = 4 OR reg_privilege_type = 5 OR reg_privilege_type = 6)
$blockedList LIMIT 0 , $limit");
return $members;
}
public function GetAllCountries()
{
$members = $this->db->select("SELECT * FROM country");
return $members;
}
function getSuccStories(){
$data=$this->db->select("SELECT succstorydetails.*,succimagedetails.*
FROM succstorydetails INNER JOIN succimagedetails
ON succstorydetails.id=succimagedetails.succStoryId
WHERE succimagedetails.status=1");
return $data;
}
public function GetAllIvPrivilegeMembers()
{
$limit = '';
$numberOfViewers = $this->getLogedDetails();
if(!empty ($numberOfViewers)) {
$limit = (!empty ($numberOfViewers['0']['pri_noof_viewers'])) ?
$numberOfViewers['0']['pri_noof_viewers'] : '4';
}
if(!empty ($limit)) {
$limit = " LIMIT 0 , $limit";
}
$members = $this->db->select("SELECT * FROM register
WHERE reg_status = 1 AND (reg_privilege_type == '4' ||
reg_privilege_type = '5' || reg_privilege_type = '6')
$limit");
return $members;
}
function getLogedDetails()
{
$logedId = isset ($_SESSION['userId']) ? $_SESSION['userId'] : '0';
$members = "";
if($logedId != '0'){
$members = $this->db->select("SELECT * FROM register
LEFT JOIN privilage ON register.reg_privilege_type =
privilage.pri_id WHERE reg_bd_id = $logedId");
}
return $members;
}
function getBlockedList()
{
$userId = isset($_SESSION['userId']) ? $_SESSION['userId'] : '0';
if($userId != '0') {
$qry = "SELECT GROUP_CONCAT(`blt_to`) AS blockedId FROM black_list WHERE blt_from = '$userId'";
$result = $this->db->select($qry);
return $result['0']['blockedId'];
}
}
function chatList()
{
$userId = isset($_SESSION['userId']) ? $_SESSION['userId'] : '0';
$result='';
if($userId != '0') {
$qry = "SELECT * FROM register RIGHT JOIN lagin ON register.reg_bd_id = lagin.log_register_id
WHERE register.reg_bd_id != $userId";
$result = $this->db->select($qry);
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment