<?php

class RoleMod extends DbMod{

	function RoleMod($ArrMsSp){
		parent::__construct($ArrMsSp);
		return true;
	}

  function GetFromDb($VarSqlName = 'SqlAll', $VarSqlGet = 'GetAll', $VarWhere = '', $VarOrder = '', $VarLimit = '', $VarJoinOn = ''){
    $ArrSqlArray['SqlAll']['select'] = 't1.role_id, t1.role_name, t1.role_session, t2.users_id';
    $ArrSqlArray['SqlAll']['from'] = $this->VarTableRole .' AS t1';
    $ArrSqlArray['SqlAll']['leftjoin'] =  $this->VarTableUsersRole .' AS t2 ON t1.role_id = t2.role_id';
    if('' != $VarJoinOn){
      $ArrSqlArray['SqlAll']['leftjoin'] .= ' AND '. $VarJoinOn;
    }
    if('' != $VarWhere){
      $ArrSqlArray['SqlAll']['where'] = $VarWhere;
    }
    ///
    $ArrSqlArray['SqlByUsersId']['select'] = 't1.role_id';
    $ArrSqlArray['SqlByUsersId']['from'] = $this->VarTableRole .' AS t1, '. $this->VarTableUsersRole .' AS t2';
    $ArrSqlArray['SqlByUsersId']['where'] = 't1.role_id = t2.role_id';
    if('' != $VarWhere){
      $ArrSqlArray['SqlByUsersId']['where'] .= ' AND '. $VarWhere;
    }
//    if('' != $VarOrder){
//      $ArrSqlArray['SqlAll']['order'] = $VarOrder;
//    }
//    if('' != $VarLimit){
//      $ArrSqlArray['SqlAll']['limit'] = $VarLimit;
//    }
    //
    $ArrResult = $this->DbGet($ArrSqlArray[$VarSqlName], $VarSqlGet);
  	return $ArrResult;
	}
}
?>