Next4Me
 All Data Structures Files Functions Variables
application/models/tplContexts.php
Go to the documentation of this file.
00001 <?php
00014 class TplContexts   extends Zend_Db_Table_Abstract {
00015         protected $_name="tplContexts"; 
00016         protected $_primary="IdTplContext"; 
00017         //==== Start AddEditTplContexts =========================================================================
00027         function AddEditTplContexts($entity) {
00028                         // function implementation
00029             $resultId = 0;
00030             $page="tplContexts.php";
00031             $method="AddEditTplContexts";
00032             $result=json_encode($entity);
00033             $message="";
00034             $type="1";
00035             $this->ErrorCode = new ErrorCode;
00036             $this->Log = new Log;
00037 
00038             try{
00039                 if ($entity['IdTplContext']=="0"){
00040                     $k=$this->insert($entity);
00041                     $k=$this->getAdapter()->lastInsertId();
00042                     $resultCode=$k; 
00043                 }else{
00044                     $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00045                             ->from("tplContexts","*")
00046                             ->where("IdTplContext=?",$entity['IdTplContext'])
00047                     );
00048                 if($rows==null){
00049                     $resultId = 3043;
00050                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00051                     $resultCode=$r['Message'];
00052                     $message=$r['Message'];
00053                     $type=3;    
00054                 }else{
00055                     $this->update(array(
00056                         "Name" => $entity['Name'], 
00057                         "Description" => $entity['Description'], 
00058                     ),$this->getAdapter()->quoteInto('IdTplContext=?',$entity['IdTplContext']));
00059                     $k=$entity['IdTplContext'];
00060                     $resultCode=$k;
00061                 }
00062                 }
00063                 
00064             }
00065             catch(Exception $e){
00066                 $resultCode=$e->getMessage();
00067                 $resultId=101;       
00068                 $type=3;
00069             }
00070                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00071                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00072          return $response;
00073         }
00074         //============ End AddEditTplContexts ==============================================================
00075 
00076 
00077         //==== Start DeleteTplContexts =========================================================================
00086         function DeleteTplContexts($entity) {
00087                         // function implementation
00088             $resultId = 0;
00089             $page="tplContexts.php";
00090             $method="DeleteTplContexts";
00091             $result=json_encode($entity);
00092             $message="";
00093             $type="1";
00094             $this->ErrorCode = new ErrorCode;
00095             $this->Log = new Log;
00096 
00097             try{
00098                 $rows = $this->fetchRow($this->select()->setIntegrityCheck(false)
00099                             ->from("tplContexts","*")
00100                             ->where("IdTplContext=?",$entity['IdTplContext'])
00101                     );
00102                 if($rows==null){
00103                     $resultId = 3044;
00104                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00105                     $resultCode=$r['Message'];
00106                     $message=$r['Message'];
00107                     $type=3;    
00108                 }else{
00109                     $chld = $this->fetchRow($this->select()->setIntegrityCheck(false)
00110                             ->from("tplContextConditions","*")
00111                             ->where("IdTplContext=?",$entity['IdTplContext'])
00112                     );
00113                 if($chld==null){
00114                     $k=$this->delete($this->getAdapter()->quoteInto("IdTplContext=?",$entity['IdTplContext']));
00115                     $resultCode="Date sterse";
00116                 }else{
00117                     $resultId = 4008;
00118                     $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00119                     $resultCode=$r['Message'];
00120                     $message=$r['Message'];
00121                     $type=3;    
00122                 }
00123                 }
00124             }
00125             catch(Exception $e){
00126                 $resultCode=$e->getMessage();
00127                 $resultId=101;       
00128                 $type=3;
00129             }
00130                 $this->Log->save($page,$method,$result,$resultId.'=>'.$resultCode,$type);
00131                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00132             return $response;
00133         }
00134         //============ End DeleteTplContexts ==============================================================
00135 
00136 
00137         //==== Start GetTplContexts =========================================================================
00145         function GetTplContexts($entity) {
00146                         // function implementation
00147             $resultId = 0;
00148             $page="tplContexts.php";
00149             $method="GetTplContexts";
00150             $result=json_encode($entity);
00151             $message="";
00152             $type="1";
00153             $this->ErrorCode = new ErrorCode;
00154             $this->Log = new Log;
00155 
00156             try{
00157                  $rows = $this->fetchAll($this->select()->setIntegrityCheck(false)
00158                             ->from("tplContexts","*")
00159                             ->where("IdTplContext=?",$entity['IdTplContext'])
00160                             ->orWhere("0=?", $entity['IdTplContext'])
00161                     );
00162             if(count($rows)!=0){
00163                 foreach($rows as $row){
00164                     $resultCode[]=array("IdTplContext" => $row->IdTplContext,
00165                         "Name" => $row->Name, 
00166                         "Description" => $row->Description, );
00167                 }
00168             }else{
00169                 $resultId = 3045;
00170                 $r=$this->ErrorCode->GetErrorCode($resultId,Zend_Registry::get('language'));
00171                 $resultCode=$r['Message'];
00172                 $message=$r['Message'];
00173                 $type=3;    
00174             }
00175             }
00176             catch(Exception $e){
00177                 $resultCode=$e->getMessage();
00178                 $resultId=101;       
00179                 $type=3;
00180             }
00181                 $this->Log->save($page,$method,$result,$resultId.'=>'.json_encode($resultCode),$type);
00182                 $response=array("resultId"=>$resultId,"resultCode"=>$resultCode);
00183          return $response;
00184         }
00185         //============ End GetTplContexts ==============================================================
00186 
00187 }
00188 
00189 ?>