Update query with returning
#1
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?
Reply
#2
You can't return a value from an update query, in MyBB or otherwise, just the number of affected rows.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#3
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
Reply
#4
Oh, I assumed it was MySQL, my bad! Glad I pointed you in the right direction by accident Toungue
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)