summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlezvous.ca>2008-06-22 10:56:44 -0400
committerEvan Prodromou <evan@controlezvous.ca>2008-06-22 10:56:44 -0400
commit73921da0f34dafd0ba5cc31b298307360f7d18c9 (patch)
tree4d8b6cb2862ad7233a8d6d0c509b875d8222e1ec /classes
parent1fcdecbd2b527ad63a322ee87fa5f83b508307b9 (diff)
add a method to update key fields in User
darcs-hash:20080622145644-34904-92549d9bb68251214c4dc370f6e2a56f516ceecb.gz
Diffstat (limited to 'classes')
-rw-r--r--classes/User.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php
index d750c7847..e8281a723 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -61,4 +61,23 @@ class User extends DB_DataObject
$sub->subscribed = $other->id;
return $sub->find();
}
+
+ # 'update' won't write key columns, so we have to do it ourselves.
+
+ function updateKeys(&$orig) {
+ $parts = array();
+ foreach (array('nickname', 'email') as $k) {
+ if ($this->$k != $orig->$k) {
+ $parts[] = $k . '="' . $this->$k . '"';
+ }
+ }
+ if (count($parts) == 0) {
+ # No changes
+ return;
+ }
+ $toupdate = implode(', ', $parts);
+ $qry = 'UPDATE ' . $this->tableName() . ' SET ' . $toupdate .
+ ' WHERE id = ' . $this->id;
+ return $this->query($qry);
+ }
}