Location: PHPKode > projects > MembersGear > membersgear/includes/upsell_product_class.php
<?php
 
 require_once "peardb_class.php";
  require_once INCLUDE_DIR."/master_class.php"; 
     
 class upsell_product_class extends peardb_class
 {  
 
     
                
            function View($pQuery, $pValues=false, $types=true, $pStart=0, $pEnd=0)
            {
                /*
                global $mdb2;    
                $result;  
         
                $query      = 'SELECT * FROM tbluser1 t limit 10;';
                $resultset  = $mdb2->query($query);
                
                if(PEAR::isError($resultset)) 
                {
                    die("Failed to issue query, error message : " . $resultset->getMessage());
                }
                
                while($row = $resultset->fetchRow(MDB2_FETCHMODE_ASSOC))
                {
                    $result[] = $row;
                }
                                                                                                                         
                return  $result;   
                */
                //print_r($pParameters);
                
                return $this->BaseView($pQuery,$pValues,$types,$pStart,$pEnd);
                
            }
            
            function Update($pQuery, $pValues=false, $types=true)
            { 
               
                return $this->BaseUpdate($pQuery, $pValues, $types);
            
            }

            
            function Insert($pQuery, $pValues=false, $types=true)
            { 
            
                return $this->BaseInsert($pQuery, $pValues, $types);
            
            }
            
             function delete($pQuery, $pValues=false, $types=true)
            {
                
              return $this->BaseDelete($pQuery, $pValues,null);
                
            } 

            
             function getUpsellProduct($prodId)
            {
            
                
                $query= "SELECT  p.id,p.name  FROM ".TABLE_PREFIX."products p left join ".TABLE_PREFIX."productpaymentoptions ps on p.id=ps.productid 
                            WHERE  p.`IsApproved`=1
                              and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
                              and (p.`isprohibited`=0 or p.`isprohibited` is null)
                              and p.`islinkedwithpaygear`=1
                              and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
                              and (p.isonetimeoffer=0)
                              and (ps.issubscription=0)
                              and (p.price > 0) 
                              and p.id!=$prodId order by name";
                              
               
        
                $result = $this->View($query);  
                
                if(is_array($result))
                {
                     if(sizeof($result))
                     {
                         $laallProduct=array();  
                        foreach($result as $key=>$value)
                        {
                         $laallProduct[$value['id']]=$value['name'];
                        } 
                     }
                     else
                     {
                         $laallProduct=null;
                         
                     }   
                 }
                else
                {    
                    $laallProduct=null;
                
                }  
                 return  $laallProduct;
            
            }
            
            function GetSpecificUpsellProduct($pid,$level)
            {
            
                 $query= "SELECT  *  FROM ".TABLE_PREFIX."productupsells  where mainproductid=$pid and  upselllevel=$level";
                 $result = $this->View($query);  
                 return $result;
            
            }
            
            
           function GetSpecificUpsellProduct_yes($pid,$level)
            {
            
                 $query= "SELECT  *  FROM ".TABLE_PREFIX."productupsells  where yesbuttonupsellproductid=$pid and  upselllevel=$level";
                 $result = $this->View($query);  
                 return $result;
            
            }
            
              function GetMainProductFromUpsellProduct($paygearUpsellProId)
            {
            
                 $query= "SELECT  *  FROM ".TABLE_PREFIX."productupsells  where paygear_productupsells_id=$paygearUpsellProId limit 1 ";
                 $result = $this->View($query);  
                 return $result;
            
            }
            
            function deleteUpsell($pid)
            {
            
                 $query= "delete from ".TABLE_PREFIX."productupsells where mainproductid=$pid";
                 $result = $this->View($query);  
                 return $result;
            
            } 
            
             function getMembersgearProductIdFromPaygearProductId($paygearProductId)
            {
            
                 $query= "SELECT  id  FROM ".TABLE_PREFIX."products  where paygear_productid=$paygearProductId limit 1";
                 $result = $this->View($query);  
                 if($result!=false)
                     return $result[0]['id'];
                 else
                    return false;  
            
            } 
        
       
                  
        
    
  
 }   
   
   
 
    

?>
Return current item: MembersGear