Update only columns that has changed.
Its tedious to compare old column values against the new being submitted before adding the column in the query statement. But, most of the articles I read says its the most efficient.
+---------------+--------------------------+-----------------+
| username | email | lastip |
+---------------+--------------------------+-----------------+
| admin | admin@google.com.ph | 127.0.0.1 |
+---------------+--------------------------+-----------------+
In this example, current $row["email"] is compared to request $email value
/* repeat this test in every column in your table */
if ($row["email"] != $email)
{
$columns[] = "email = '$email'";
}
/* constructed sql statement would be */
$sql = "update customer set email = '$email' where username = 'admin'";
Another advantage following this convention is when there are multiple users accessing the same row. Though it sounds impossible that same row is updated at an exact same time, unless your site tops google on ranking. And even so, your SQL operation would have saved a little less resource than usual.