From 82d2d98a11234ee24dafc01e1565cdf1c4584cd7 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 28 Oct 2010 17:31:51 +0000 Subject: better documentation --- it_dbi.class | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'it_dbi.class') 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']]; -- cgit v1.2.3