MyBB Community Forums

Full Version: Update query with returning
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to do like that


$sql="UPDATE mybb_users SET ".$campo."='".$partes[3]."' WHERE uid='".$partes[1]."' RETURNING id AS afectados;";
 $respuesta=$db->query($sql);
$afectados=$db->fetch_field($respuesta, 'afectados');


but with this:

$update_array = array(
$campo => $info[4]
);
$r=$db->update_query('users', $update_array, "uid = {$nombre_usuario['uid']}","RETURNING id AS afectados;");

$afectados=$db->fetch_field($r, 'afectados');

Is possible?
You can't return a value from an update query, in MyBB or otherwise, just the number of affected rows.
In postgresql is possible but not with  $db->update_query
Well, thanks, I got it, with just affected rows, because just I need know if the update was successfully done


            $db->update_query('users', $update_array, "uid = {$nombre_usuario['uid']}");
$afectados=$db->affected_rows();


thanks and best regards
Oh, I assumed it was MySQL, my bad! Glad I pointed you in the right direction by accident Toungue