Return value of $wpdb->update() query in plugin is wrong

The return value of my update query on an empty database table is wrong even though my query syntax seems to be right. The ELSE statement is executed when I run the query on an empty table but no update entry is made in the table. What may be wrong?

    if($wpdb-update( 
        'wp_counter_cookies', 
        array( 
            'visit' = current_time( 'mysql' ), // string
        ), 
        array( 'cookie' = $counter_cookie ), 
        array( 
            '%s'    // value1
        ), 
        array( '%s' ) 
    )=== FALSE)
    {
        $table_name = $wpdb-prefix . 'counter_cookies';

        $wpdb-insert( 
            $table_name, 
            array( 
                'visit' = current_time( 'mysql' ), 
                'cookie' = $counter_cookie,
                'user' = $user,
            ), 
            array( 
                '%s', 
                '%s', 
                '%s' 
            ) 
        );                       
    }
    else
    {
        $ignore = true;
    }

Topic plugin-development Wordpress

Category Web


Changing the comparison operator to == instead of strict comparison === as suggested by @czerspalace, solved the problem because on execution of my update function no rows were updated, so 0(int) was being returned . False is only returned if there is an error.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.