<?php

class SvtextMod extends DbMod{	

	function SvtextMod($ArrMsSp){
		parent::__construct($ArrMsSp);
		return true;
	}
	
	function GetFromDb($VarSqlName = 'SqlAll', $VarSqlGet = 'GetAll', $VarWhere = '', $VarOrder = '', $VarLimit = ''){
    $ArrSqlArray['SqlAll']['select'] = 'a.*';
    $ArrSqlArray['SqlAll']['from'] = $this->VarTableSvtext .' AS a';
    if('' != $VarWhere){
      $ArrSqlArray['SqlAll']['where'] = $VarWhere;
    }
    if('' != $VarOrder){
      $ArrSqlArray['SqlAll']['order'] = $VarOrder;
    }
    if('' != $VarLimit){
      $ArrSqlArray['SqlAll']['limit'] = $VarLimit;
    }
    
    $ArrSqlArray['SqlRow']['select'] = 'a.ID, a.TEXT';
    $ArrSqlArray['SqlRow']['from'] = $this->VarTableSvtext .' AS a';
    if('' != $VarWhere){
      $ArrSqlArray['SqlRow']['where'] = $VarWhere;
    }
    ///
    $ArrSqlArray['SqlSvtextId']['select'] = 'a.ID, a.IDGLOBAL, b.STATUS_ID, b.STATUS_NAME';
    $ArrSqlArray['SqlSvtextId']['from'] = $this->VarTableSvtext .' AS a';
    $ArrSqlArray['SqlSvtextId']['leftjoin'] = $this->VarTableStatus .' AS b ON a.STATUS = b.STATUS_ID';
    if('' != $VarWhere){
      $ArrSqlArray['SqlSvtextId']['where'] = $VarWhere;
    }
    ///
    $ArrSqlArray['SqlCount']['select'] = 'count(DISTINCT a.IDGLOBAL) AS vartotal';
    $ArrSqlArray['SqlCount']['from'] = $this->VarTableSvtext .' AS a';
    if('' != $VarWhere){
      $ArrSqlArray['SqlCount']['where'] = $VarWhere;
    }
    ///
    $ArrResult = $this->DbGet($ArrSqlArray[$VarSqlName], $VarSqlGet);
  	return $ArrResult;
	}
}
?>