Topic: Extension Help - SET values in query_builder

I can't figure out why this won't update the values in MySQL. Anyone have any insight?

I've created the proper columns in the install portion of the extension.

    // check for first visit
    if (!isset($forum_user['access_time']) || $forum_user['access_time'] == '0') 
    {
        $forum_user['access_time'] = time() - 60;
    }
    if ($forum_user['g_id'] == FORUM_ADMIN) 
    {
            
    
        // rates, need to be entered into db sometime in the future
        $wood_rate = array(20,48,84,128,180,240,308,384,468,560);
        // main function for value of resource
        $rate = $wood_rate['5'] / 60 / 60; // rate per second
        $forum_user['wood_amount'] = $forum_user['wood_amount'] + (time() - $forum_user['access_time']) * $rate;
        // set values in db        
        if (!isset($bb_new_values))
        {
            $bb_query = array(
                'UPDATE'    => 'users',
                'SET'        => 'access_time = '.$forum_user['access_time'].', wood_amount = '.$forum_user['wood_amount'],
                'WHERE'        => 'id='.$forum_user['id']
            );
        $forum_db->query_build($bb_query) or error(__FILE__, __LINE__);
        }

2

Re: Extension Help - SET values in query_builder

Define FORUM_SHOW_QUERIES in your config.php and try the built SQL command directly. My guess is that $forum_user['access_time'] is in wrong format.

Also, check whether $bb_new_values is set. Because if it isn't, $bb_query will not be defined and query_build will fail.

3

Re: Extension Help - SET values in query_builder

Make sure that you are closing the db connection before the script ends too.

Re: Extension Help - SET values in query_builder

Turns out trying to use !isset() on an array returns false. smile

I just removed the if statement around the query and it works.

Thanks. smile

Re: Extension Help - SET values in query_builder

What is the command to close a db query?

Re: Extension Help - SET values in query_builder

slickplaid wrote:

What is the command to close a db query?

$forum_db->close();