Next4Me
 All Data Structures Files Functions Variables
application/models/tplContextFactors.php
Go to the documentation of this file.
00001 <?php 
00013 class TplContextFactors   extends Zend_Db_Table_Abstract {
00014         protected $_name="tplContextFactors"; 
00015         protected $_primary="IdTplContextFactor"; 
00016         //==== Start AddEditTplContextFactors =========================================================================
00030         function AddEditTplContextFactors($entity) {
00031                         // function implementation
00032             $resultId = 0;
00033             $page="tplContextFactors.php";
00034             $method="AddEditTplContextFactors";
00035             $result=json_encode($entity);
00036             $message="";
00037             $type="1";
00038             $this->ErrorCode = new ErrorCode;
00039             $this->Log = new Log;
00040 
00041             try{
00042                 if ($entity['IdTplContextFactor']=="0"){
00043                     $k=$this->insert($entity);
00044                     $k=$this->getAdapter()->lastInsertId();
00045                     $resultCode=$k;    
00046                 }else{
00047                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00048                             ->from("tplContextFactors","*")
00049                             ->where("IdTplContextFactor=?",$entity['IdTplContextFactor'])
00050                     );
00051                 if($rows!=null){
00052                     $IdTplContextCondition=$rows->IdTplContextCondition;
00053                     if($IdTplContextCondition==$entity['IdTplContextCondition']){
00054                     $this->update(array(
00055                         "Name" => $entity['Name'], 
00056                         "Type" => $entity['Type'], 
00057                         "Function" => $entity['Function'], 
00058                         "Value" => $entity['Value'], 
00059                         "IdTplContextCondition" => $entity['IdTplContextCondition'], 
00060                     ),$this->getAdapter()->quoteInto('IdTplContextFactor=?',$entity['IdTplContextFactor']));
00061                     $k=$entity['IdTplContextFactor'];
00062                     $resultCode=$k;    
00063                     }else{
00064                     $resultId = 5012;
00065                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00066                     $resultCode=$r['Message'];
00067                     $message=$r['Message'];
00068                     $type=3;    
00069                 }
00070                 }else{
00071                     $resultId = 3049;
00072                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00073                     $resultCode=$r['Message'];
00074                     $message=$r['Message'];
00075                     $type=3;    
00076                 }
00077                 
00078                 }
00079                     
00080                 
00081             }
00082             catch(Exception $e){
00083                 $resultCode=$e->getMessage();
00084                 $resultId=101;       
00085                 $type=3;
00086             }
00087                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00088                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00089          return $response;
00090         }
00091         //============ End AddEditTplContextFactors ==============================================================
00092 
00093 
00094         //==== Start DeleteTplContextFactors =========================================================================
00102         function DeleteTplContextFactors($entity) {
00103                         // function implementation
00104             $resultId = 0;
00105             $page="tplContextFactors.php";
00106             $method="DeleteTplContextFactors";
00107             $result=json_encode($entity);
00108             $message="";
00109             $type="1";
00110             $this->ErrorCode = new ErrorCode;
00111             $this->Log = new Log;
00112 
00113             try{
00114                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00115                             ->from("tplContextFactors","*")
00116                             ->where("IdTplContextFactor=?",$entity['IdTplContextFactor'])
00117                     );
00118                 if($rows==null){
00119                     $resultId = 3050;
00120                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00121                     $resultCode=$r['Message'];
00122                     $message=$r['Message'];
00123                     $type=3;    
00124                 }else{
00125                 $k=$this->delete($this->getAdapter()->quoteInto("IdTplContextFactor=?",$entity['IdTplContextFactor']));
00126                 $resultCode="Date sterse";
00127                 }
00128             }
00129             catch(Exception $e){
00130                 $resultCode=$e->getMessage();
00131                 $resultId=101;       
00132                 $type=3;
00133             }
00134                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00135                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00136             return $response;
00137         }
00138         //============ End DeleteTplContextFactors ==============================================================
00139 
00140 
00141         //==== Start GetTplContextFactors =========================================================================
00149         function GetTplContextFactors($entity) {
00150                         // function implementation
00151             $resultId = 0;
00152             $page="tplContextFactors.php";
00153             $method="GetTplContextFactors";
00154             $result=json_encode($entity);
00155             $message="";
00156             $type="1";
00157             $this->ErrorCode = new ErrorCode;
00158             $this->Log = new Log;
00159 
00160             try{
00161                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00162                             ->from("tplContextFactors","*")
00163                             ->where("IdTplContextFactor=?",$entity['IdTplContextFactor'])
00164                             ->orWhere("0=?", $entity['IdTplContextFactor'])
00165                     );
00166             if(count($rows)!=0){
00167                 foreach($rows as $row){
00168                     $resultCode[]=array("IdTplContextFactor" => $row->IdTplContextFactor,
00169                         "Name" => $row->Name, 
00170                         "Type" => $row->Type, 
00171                         "Function" => $row->Function, 
00172                         "Value" => $row->Value,
00173                         "IdTplContextCondition" => $row->IdTplContextCondition, );
00174                 }
00175             }else{
00176                 $resultId = 3051;
00177                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00178                 $resultCode=$r['Message'];
00179                 $message=$r['Message'];
00180                 $type=3;    
00181             }
00182             }
00183             catch(Exception $e){
00184                 $resultCode=$e->getMessage();
00185                 $resultId=101;       
00186                 $type=3;
00187             }
00188                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00189                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00190          return $response;
00191         }
00192         //============ End GetTplContextFactors ==============================================================
00193 
00194 }
00195 
00196 ?>