Quantcast
Viewing all articles
Browse latest Browse all 8245

joker1234 on "WPDB Update only the first row"

I have this code, and I want to update only the first row found where the times column is equal to 0, but it updates all.

$dbHost = 'host';
$dbUser = 'user';
$dbPass = 'pass';
$dbName = 'name';

$mydb = new wpdb($dbUser,$dbPass,$dbName,$dbHost);

$table_name = 'users';

$data = array(
	'username' => 'name'
);

$where = array( 'times' => 0 );

$format = array( '%s' );

$where_format = array( '%d' );

$mydb->update( $table_name, $data, $where, $format, $where_format );

How can I achieve this? Thanks.


Viewing all articles
Browse latest Browse all 8245

Trending Articles