Re: MySQL Update Quandry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This might be easier using the mysqli extension, but the function mysql_info 
will give you a string result indicating information about the most recent 
string, just as you would from the command line.

The rows matched is what you're looking for, which appears first in the 
string, so you should fairly easily be able to parse the string for the 
first integer (there might even be a function like get_int_value that will 
return the integer value of a string based on the first number it finds - 
PLEASE SOMEONE EXPAND ON THIS).

But either way, once you've extracted the rows matched from mysql_info your 
problem should be solved.


Matt


"maestro" <maestroQC@xxxxxxxxx> wrote in message 
news:4C.DE.56276.4B357834@xxxxxxxxxxxxxxx
> Greetings,
>
> I am doing an update to a table as such:
>
> class DB {
> ....
>
>   function updateMember($email, $password, $postalCode,
>                         $language, $id, $word) {
>
>   ...
>     if (!(@ mysql_query($query, $connection))) {
>       $this->errors = array(mysql_errno(), mysql_error());
>       $error = new Error();
>       $error->logError($this->errors);
>       return false;
>     }
>
>     if (mysql_affected_rows() == 0) {
>       return false;
>     }
>
>     return true;
>   }
> }
>
>
>
> If the user supplies a wrong $word the mysql_affected_rows will be 0 and 
> the method will return false. This is fine.
> My problem arises when the user supplies data that has not changed. The 
> mysql_affected_rows will be 0 as well.
> How can I know the difference between an update that fails due to a failed 
> where clause and one that updates nothing?
>
> TIA,
> Glenn 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux