Location: PHPKode > projects > MembersGear > membersgear/includes/peardb_class.php
<?php
if(!class_exists('peardb_class')){  
class peardb_class
{
    /*
    * e.g. $types = array('integer', 'text'); 
    */
    
    function BaseView($pQuery, $pValues=false, $types=true, $pStart=0, $pEnd=0)
    {
        global $mdb2;  
        
        $dsn['username']=MEMBERSGEAR_DB_USER; 
        $dsn['password'] =MEMBERSGEAR_DB_PASSWORD; 
        $dsn['hostspec'] =MEMBERSGEAR_DB_HOST; 
        $dsn['phptype'] =MEMBERSGEAR_DB_TYPE; 

        $mdb2 =& MDB2::factory($dsn);
        $mdb2->setDatabase(MEMBERSGEAR_DB_NAME);
         
         //print_r($mdb2);
         
         $result;
         
         if(trim($pQuery) !='')
         {
             //Set Limit if $pStart and $pEnd 
             
             if($pStart>0 && $pEnd>0)
                $pQuery.=" limit ".$pStart.", ".$pEnd;
             else if($pStart>0)  
                $pQuery.=" limit ".$pStart;    
            
            
            if(is_array($pValues) && sizeof($pValues)>0)
            {
                //MDB2_PREPARE_MANIP is required if you wish to manipulate data, and not return any values. 
                //MDB2_PREPARE_RESULT is used if you wish to run a prepared statement and have data returned 
                $statement = $mdb2->prepare($pQuery, $types, MDB2_PREPARE_RESULT);
                $resultset = $statement->execute($pValues);

                if(PEAR::isError($resultset)) 
                {
                    die("Failed to issue query, error message : " . $resultset->getMessage());
                }
                
                $statement->Free(); 
            } 
            else
                $resultset = $mdb2->query($pQuery);
            
            
            while($row = $resultset->fetchRow(MDB2_FETCHMODE_ASSOC))
            {
                $result[] = $row;
            }  
            
         }
         
         return isset($result)?$result:false;
    }
    
    
    
    /*
    * e.g. $types = array('integer', 'text'); 
    */
    
    function BaseUpdate($pQuery, $pValues=false, $types=true)
    {
         global $mdb2;
         
        $dsn['username']=MEMBERSGEAR_DB_USER; 
        $dsn['password'] =MEMBERSGEAR_DB_PASSWORD; 
        $dsn['hostspec'] =MEMBERSGEAR_DB_HOST; 
        $dsn['phptype'] =MEMBERSGEAR_DB_TYPE; 

        $mdb2 =& MDB2::factory($dsn);
        $mdb2->setDatabase(MEMBERSGEAR_DB_NAME);
        
         $affected_rows=0;
         
         if(trim($pQuery) !='')
         {
             //Set Limit if $pStart and $pEnd 
            
            if(is_array($pValues) && sizeof($pValues)>0)
            {
                //MDB2_PREPARE_MANIP is required if you wish to manipulate data, and not return any values. 
                //MDB2_PREPARE_RESULT is used if you wish to run a prepared statement and have data returned 
                $statement = $mdb2->prepare($pQuery, $types, MDB2_PREPARE_MANIP);
                $affected_rows = $statement->execute($pValues);

                if(PEAR::isError($affected_rows)) 
                {
                    die("Failed to issue query, error message : " . $resultset->getMessage());
                }
                $statement->free();
            }
            else
                $affected_rows = $mdb2->query($pQuery);
            
         }
         
         return $affected_rows;
    }
   
   
   
    function BaseInsert($pQuery, $pValues=false, $types=true)
    {
         global $mdb2;
         
        $dsn['username']=MEMBERSGEAR_DB_USER; 
        $dsn['password'] =MEMBERSGEAR_DB_PASSWORD; 
        $dsn['hostspec'] =MEMBERSGEAR_DB_HOST; 
        $dsn['phptype'] =MEMBERSGEAR_DB_TYPE; 

        $mdb2 =& MDB2::factory($dsn);
        $mdb2->setDatabase(MEMBERSGEAR_DB_NAME);
          
         $affected_rows=0;
         
         if(trim($pQuery) !='')
         {
             //Set Limit if $pStart and $pEnd 
            
            if(is_array($pValues) && sizeof($pValues)>0)
            {
                //MDB2_PREPARE_MANIP is required if you wish to manipulate data, and not return any values. 
                //MDB2_PREPARE_RESULT is used if you wish to run a prepared statement and have data returned 
                $statement = $mdb2->prepare($pQuery, $types, MDB2_PREPARE_MANIP);
                $affected_rows = $statement->execute($pValues);

                if(PEAR::isError($affected_rows)) 
                {
                    die("Failed to issue query, error message : " . $resultset->getMessage());
                }
                $statement->free();
            }
            else
                $affected_rows = $mdb2->query($pQuery);
            
         }
         
         return $affected_rows;
    }
    function BaseDelete($pQuery, $pValues=false, $types=true)
    {
         global $mdb2;
        $dsn['username']=MEMBERSGEAR_DB_USER; 
        $dsn['password'] =MEMBERSGEAR_DB_PASSWORD; 
        $dsn['hostspec'] =MEMBERSGEAR_DB_HOST; 
        $dsn['phptype'] =MEMBERSGEAR_DB_TYPE; 

        $mdb2 =& MDB2::factory($dsn);
        $mdb2->setDatabase(MEMBERSGEAR_DB_NAME);
        
          
         $affected_rows=0;
         
         if(trim($pQuery) !='')
         {
             //Set Limit if $pStart and $pEnd 
            
            if(is_array($pValues) && sizeof($pValues)>0)
            {
                //MDB2_PREPARE_MANIP is required if you wish to manipulate data, and not return any values. 
                //MDB2_PREPARE_RESULT is used if you wish to run a prepared statement and have data returned 
                $statement = $mdb2->prepare($pQuery, $types, MDB2_PREPARE_MANIP);
                $affected_rows = $statement->execute($pValues);

                if(PEAR::isError($affected_rows)) 
                {
                    die("Failed to issue query, error message : " . $resultset->getMessage());
                }
                $statement->free();
            }
            else
                $affected_rows = $mdb2->query($pQuery);
            
         }
         
         return $affected_rows;
    }
    
    
    
    
}
     
     
}
?>
Return current item: MembersGear