View Single Post
Old 01-16-2009, 09:23 AM   #36 (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

Some minor details about 2 of your functions that I don't think will work with the SQL class. Concerns the graboptions and name2id functions.


graboptions:
Looks like this currently
PHP Code:
private function grabOptions()
    {
        
$options $this->dbobj->exeQuery("SELECT option_id, option_name, option_value FROM `$this->table`");

        if ( 
$options->rows() > )
        {

            while ( 
$options->getFetch(falsetrue) )
            {
                
                
$this->configinfo["$options[option_name]"] = $options[option_value];
                
            }

            return 
true;

        }
        
        return 
false;

    } 
- The $options variable is pretty useless, since the assignment to it comes from the result of exeQuery, which only returns $this, which basicly means that you're assigning $options = $this->db;. You don't need the $option variable there.

- The rows function is called getRows

- The while loop looks a little suspicious, not sure if it would work. If you check the SQL class, you see that when I fetch the array, I already loop it there with a while loop. So you don't need to use a while loop in your code, you can skip it. Use a foreach instead to get the results.

- You should always use ' whenever you're checking a specific value in an array: $options['option_value']

- If you're checking a value inside an array, against a variable, I don't think it's neccessary to use ": $this->configinfo[$options['option_value']]

Something like this would be more accurate I think:
PHP Code:
private function grabOptions()
{
    
$sql "SELECT option_id, option_name, option_value FROM `$this->table`";

    if ( 
$this->dbobj->getRows($sql) > )
    {

        
$options $this->dbobj->getFetch(falsetrue);

        foreach( 
$options as $option )            
        {
                
            
$this->configinfo[$option['option_name']] = $option['option_value'];
                
        }

        return 
true;

    }
        
    return 
false;


But.. haven't tested so I don't know. It should be more correct with the SQL class however.
__________________
Tanax is offline  
Reply With Quote