mysql_affected_cols() ??? or equivalent?

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

 



Is it possible to find out how many columns from a row were updated in a
single update SQL command?

For example:

$x = mysql_query("update users set un={$un},pw={$pw},ln={$ln},fn={$fn} where id={$id}");

And the function (something like mysql_affected_cols()) would return 0 if
everything stayed the same (like mysql_affected_rows() does), or if
something changed, the number of columns that were changed.

So if only the password and first name were changed, mysql_affected_cols()
would return 2.

>From PHP.net regarding mysql_affected_rows():
    When using UPDATE, MySQL will not update columns where the new value is
    the same as the old value. This creates the possiblity that
    mysql_affected_rows() may not actually equal the number of rows matched,
    only the number of rows that were literally affected by the query.

Any ideas?

Peter
---------------------------------------------------------------------------
Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------


-- 
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