summaryrefslogtreecommitdiff
path: root/it_dbi.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_dbi.class')
-rw-r--r--it_dbi.class20
1 files changed, 18 insertions, 2 deletions
diff --git a/it_dbi.class b/it_dbi.class
index ab132ff..1c30d6f 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -719,6 +719,8 @@ function insert($tags = array(), $command = "INSERT")
$id = ($this->_p['autoincrement'] && !isset($tags[$this->_p['keyfield']])) ? mysqli_insert_id($this->_link) : $tags[$this->_p['keyfield']];
if ($this->_p['keyfield'] && !$this->read($id) && $this->_p['safety'])
$this->_fatal("insert(): can't read record back (key truncated?), id=\"$id\"");
+
+ $this->_touchedids[$this->_key] = true;
}
else
$this->clear(false);
@@ -782,6 +784,8 @@ function update($tags = array(), $where = null)
}
}
+ $this->_touchedids[$this->_key] = true;
+
return $result;
}
@@ -811,6 +815,20 @@ function delete($query = null)
/**
+ * Delete records matching query which were not touched since creation of this object or last call of this func
+ */
+function delete_untouched($query = null)
+{
+ if ($this->select($query))
+ while ($this->iterate())
+ if (($id = $this->_key) && !$this->_touchedids[$id])
+ $result += $this->delete();
+
+ unset($this->_touchedids);
+ return (int)$result;
+}
+
+/**
* Escapes a string for use in a DB query
* @param The string to be quoted
* @return The quoted value
@@ -953,5 +971,3 @@ static function get($id)
}
} /* End class it_dbi */
-
-?>