Hi. Don mailed this only to me, but from the content it was obviously intended for the list (or at least [EMAIL PROTECTED]). ----- Forwarded message from Don Read <[EMAIL PROTECTED]> ----- > From: Don Read <[EMAIL PROTECTED]> > To: Benjamin Pflugmann <[EMAIL PROTECTED]> > Subject: Re: update > Date: Wed, 21 Mar 2001 03:58:39 -0600 (CST) > X-Mailer: XFMail 1.4.0 on FreeBSD > > > On 21-Mar-01 Benjamin Pflugmann wrote: > > Hi. > > > > On Mon, Mar 19, 2001 at 04:19:32PM +0800, [EMAIL PROTECTED] wrote: > >> I want to use mysql_affected_rows to determine whether the sql statement is > >> executed or not found. > >> If mysql_affected_rows return 0,I take it as not found. > >> But If I update a value to the value it already was, > >> (It means if some value is 'test', and in my sql statement I update this > >> value to 'test') > >> mysql_affected_rows also return 0, so I take it as not_found,but it is not > >> I > >> want. > >> How should I do? > > > Why are you updating blind ? Don't do that. > > $qry="select * from da_table where da_value <> 'test'"; > $res=mysql_query($qry) > or die ('<P>Error ' .mysql_errno() .' '.mysql_error()."<BR>\n"); > > if (mysql_num_rows($res)) { > $qry="update da_table set da_value='test' where da_value <> 'test'"; > $res=mysql_query($qry); > if ($res) { > echo 'Updated:', mysql_affected_rows(), '<br>'; > } > } else { > echo 'nothing to do !<br>'; > } > > > > > > This behaviour is the expected, documented one and even the special > > case you want is documented. There is a config variable to change the > > default behaviour. Have a look at the manual. Don't know the section > > from head, but shouldn't be hard to find. > > > > http://www.php.net/manual/en/function.mysql-affected-rows.php > > -- > Don Read [EMAIL PROTECTED] > -- If you are going to sin, sin against God, not the bureaucracy. > God will forgive you but the bureaucrats won't. ----- End forwarded message ----- --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php