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