summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Walker <walkah@walkah.net>2010-06-17 13:44:17 -0400
committerJames Walker <walkah@walkah.net>2010-06-17 13:44:17 -0400
commitb66709215309126969104ad114874360785f3d57 (patch)
tree31129298c0f44b6b235c7010a43b7647292355aa
parentd65d9826811c5e9b2aec01aa89abffbfbee535f8 (diff)
adding a Status_network::updateKeys() method, since DB_DataObject update doesn't do keys.
-rw-r--r--classes/Status_network.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/classes/Status_network.php b/classes/Status_network.php
index 4a1f2c374..64016dd79 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -144,6 +144,35 @@ class Status_network extends Safe_DataObject
return parent::update($orig);
}
+ /**
+ * DB_DataObject doesn't allow updating keys (even non-primary)
+ */
+ function updateKeys(&$orig)
+ {
+ $this->_connect();
+ foreach (array('hostname', 'pathname') as $k) {
+ if (strcmp($this->$k, $orig->$k) != 0) {
+ $parts[] = $k . ' = ' . $this->_quote($this->$k);
+ }
+ }
+ if (count($parts) == 0) {
+ // No changes
+ return true;
+ }
+
+ $toupdate = implode(', ', $parts);
+
+ $table = common_database_tablename($this->tableName());
+ $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
+ ' WHERE nickname = ' . $this->_quote($this->nickname);
+ $orig->decache();
+ $result = $this->query($qry);
+ if ($result) {
+ $this->encache();
+ }
+ return $result;
+ }
+
function delete()
{
$this->decache(); # while we still have the values!