diff options
author | Urban Müller | 2010-10-28 17:31:51 +0000 |
---|---|---|
committer | Urban Müller | 2010-10-28 17:31:51 +0000 |
commit | 82d2d98a11234ee24dafc01e1565cdf1c4584cd7 (patch) | |
tree | 10f3e0b9df714347fa2ccb2f04c9ef86b9aef520 | |
parent | 3835b993ce2f720c59e7067861f924d2705ec1e1 (diff) | |
download | itools-82d2d98a11234ee24dafc01e1565cdf1c4584cd7.tar.gz itools-82d2d98a11234ee24dafc01e1565cdf1c4584cd7.tar.bz2 itools-82d2d98a11234ee24dafc01e1565cdf1c4584cd7.zip |
better documentation
-rw-r--r-- | it_dbi.class | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/it_dbi.class b/it_dbi.class index 3ca2fc1..0457142 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -648,11 +648,12 @@ function replace($tags = array()) /** - * Update a record in a table - * @param $tags Additional key => value pairs (these have priority over member vars) + * Update current record or a number of records given by where condition + * @param $tags key => value pairs (these have priority over changes in member vars) + * @param $where condition to select records to be modified (if not current record) * Does not destroy internal state of last select() call */ -function update($tags = array(), $query = null) +function update($tags = array(), $where = null) { $this->_connect(); $result = true; @@ -660,12 +661,12 @@ function update($tags = array(), $query = null) /* Pre-processing, $tags is passed by reference and may be modified here */ $this->_write_pre_process($tags); - if ($set = $this->_set($tags, isset($query))) + if ($set = $this->_set($tags, isset($where))) { - if (!isset($query)) - $query = array($this->_p['keyfield'] => $this->_data[$this->_p['keyfield']]); + if (!isset($where)) + $where = array($this->_p['keyfield'] => $this->_data[$this->_p['keyfield']]); - if ($result = $this->query("UPDATE {$this->_p['table']} $set " . $this->_where($query, $this->_link))) + if ($result = $this->query("UPDATE {$this->_p['table']} $set " . $this->_where($where, $this->_link))) { if (array_key_exists($this->_p['keyfield'], $tags)) # Did we just update the key? $this->_key = $tags[$this->_p['keyfield']]; |