View Single Post
Old 11-16-2008, 06:53 PM   #2 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

php Code:
public function loadFetch($assoc = FALSE, $sql = NULL) {
           
            unset($this->query_fetch);
            empty($this->query_fetch);
       
            if($sql == NULL)
            {
               
                if(isset($this->query_result))
                {
                   
                    if($assoc == FALSE)
                    {
                       
                        while($fetch = mysql_fetch_array($this->query_result))
                        {
                           
                            $this->query_fetch[] = $fetch;
                           
                        }
                       
                        if(!$this->query_fetch)
                        {
                           
                            throw new Exception('An error occured while fetching the array.' . mysql_error());
                           
                        }
                       
                        else return $this;
                       
                    }
                   
                    elseif($assoc == TRUE)
                    {
                       
                        while($fetch = mysql_fetch_array($this->query_result, MYSQL_ASSOC))
                        {
                           
                            $this->query_fetch[] = $fetch;
                           
                        }
                       
                        if(!$this->query_fetch)
                        {
                           
                            throw new Exception('An error occured while fetching the array.' . mysql_error());
                           
                        }
                       
                        else return $this;
                       
                    }
                   
                    else throw new Exception('First parameter can only be TRUE or FALSE.');
                   
                }
               
                else throw new Exception('No query has been executed.');
               
            }
           
            else
            {
               
                if($assoc == FALSE)
                {
                   
                    while($fetch = mysql_fetch_array($sql))
                    {
                       
                        $this->query_fetch[] = $fetch;
                       
                    }
                   
                    if(!$this->query_fetch)
                    {
                       
                        throw new Exception('An error occured while fetching the array.');
                       
                    }
                   
                    else return $this;
                   
                }
               
                elseif($assoc == TRUE)
                {
                   
                    while($fetch = mysql_fetch_array($sql, MYSQL_ASSOC))
                    {
                       
                        $this->query_fetch[] = $fetch;
                       
                    }
                   
                    if(!$this->query_fetch)
                    {
                       
                        throw new Exception('An error occured while fetching the array.');
                       
                    }
                   
                    else return $this;
                   
                }
               
                else throw new Exception('First parameter can only be TRUE or FALSE.');
               
            }
           
        }

You will have to edit it though so it works with your core.
This is what I use anyways..
__________________
Tanax is offline  
Reply With Quote
The Following User Says Thank You to Tanax For This Useful Post:
sarmenhb (11-17-2008)