diff options
| author | Damien Regad <dregad@mantisbt.org> | 2019-11-23 18:03:41 +0100 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2019-11-23 18:03:41 +0100 |
| commit | c22b56c90cf3803ee8a6cd1c907b8167a7e8b452 (patch) | |
| tree | ade5eb6f0e3cd409e09f1c92ace2e256b1f52c9c /adodb-lib.inc.php | |
| parent | 6864830e7590a681c3de2ba5c77a4e788919fef7 (diff) | |
| download | adodb-c22b56c90cf3803ee8a6cd1c907b8167a7e8b452.tar.gz adodb-c22b56c90cf3803ee8a6cd1c907b8167a7e8b452.tar.bz2 adodb-c22b56c90cf3803ee8a6cd1c907b8167a7e8b452.zip | |
Fix indentation
Diffstat (limited to 'adodb-lib.inc.php')
| -rw-r--r-- | adodb-lib.inc.php | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/adodb-lib.inc.php b/adodb-lib.inc.php index 81ee668e..0e5853c0 100644 --- a/adodb-lib.inc.php +++ b/adodb-lib.inc.php @@ -135,88 +135,88 @@ function _array_change_key_case($an_array) function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc) { - // Add Quote around table name to support use of spaces / reserve keywords - $table=sprintf('%s%s%s', $zthis->nameQuote,$table,$zthis->nameQuote); - - if (count($fieldArray) == 0) return 0; - $first = true; - $uSet = ''; + // Add Quote around table name to support use of spaces / reserve keywords + $table=sprintf('%s%s%s', $zthis->nameQuote,$table,$zthis->nameQuote); - if (!is_array($keyCol)) { - $keyCol = array($keyCol); - } - foreach($fieldArray as $k => $v) { - if ($v === null) { - $v = 'NULL'; - $fieldArray[$k] = $v; - } else if ($autoQuote && /*!is_numeric($v) /*and strncmp($v,"'",1) !== 0 -- sql injection risk*/ strcasecmp($v,$zthis->null2null)!=0) { - $v = $zthis->qstr($v); - $fieldArray[$k] = $v; - } - if (in_array($k,$keyCol)) continue; // skip UPDATE if is key + if (count($fieldArray) == 0) return 0; + $first = true; + $uSet = ''; - // Add Quote around column name to support use of spaces / reserve keywords - if ($first) { - $first = false; - $uSet = sprintf('%s%s%s=%s', $zthis->nameQuote,$k,$zthis->nameQuote,$v); - } else - $uSet .= sprintf(',%s%s%s=%s',$zthis->nameQuote,$k,$zthis->nameQuote,$v); + if (!is_array($keyCol)) { + $keyCol = array($keyCol); + } + foreach($fieldArray as $k => $v) { + if ($v === null) { + $v = 'NULL'; + $fieldArray[$k] = $v; + } else if ($autoQuote && /*!is_numeric($v) /*and strncmp($v,"'",1) !== 0 -- sql injection risk*/ strcasecmp($v,$zthis->null2null)!=0) { + $v = $zthis->qstr($v); + $fieldArray[$k] = $v; } + if (in_array($k,$keyCol)) continue; // skip UPDATE if is key - // Add Quote around column name in where clause - $where = false; - foreach ($keyCol as $v) { - if (isset($fieldArray[$v])) { - if ($where) - $where .= sprintf(' and %s%s%s=%s ', $zthis->nameQuote,$v,$zthis->nameQuote,$fieldArray[$v]); - else - $where = sprintf('%s%s%s=%s', $zthis->nameQuote,$v,$zthis->nameQuote,$fieldArray[$v]); - } - } + // Add Quote around column name to support use of spaces / reserve keywords + if ($first) { + $first = false; + $uSet = sprintf('%s%s%s=%s', $zthis->nameQuote,$k,$zthis->nameQuote,$v); + } else + $uSet .= sprintf(',%s%s%s=%s',$zthis->nameQuote,$k,$zthis->nameQuote,$v); + } - if ($uSet && $where) { - $update = "UPDATE $table SET $uSet WHERE $where"; + // Add Quote around column name in where clause + $where = false; + foreach ($keyCol as $v) { + if (isset($fieldArray[$v])) { + if ($where) + $where .= sprintf(' and %s%s%s=%s ', $zthis->nameQuote,$v,$zthis->nameQuote,$fieldArray[$v]); + else + $where = sprintf('%s%s%s=%s', $zthis->nameQuote,$v,$zthis->nameQuote,$fieldArray[$v]); + } + } - $rs = $zthis->Execute($update); + if ($uSet && $where) { + $update = "UPDATE $table SET $uSet WHERE $where"; + $rs = $zthis->Execute($update); - if ($rs) { - if ($zthis->poorAffectedRows) { - /* - The Select count(*) wipes out any errors that the update would have returned. - http://phplens.com/lens/lensforum/msgs.php?id=5696 - */ - if ($zthis->ErrorNo()<>0) return 0; - # affected_rows == 0 if update field values identical to old values - # for mysql - which is silly. + if ($rs) { + if ($zthis->poorAffectedRows) { + /* + The Select count(*) wipes out any errors that the update would have returned. + http://phplens.com/lens/lensforum/msgs.php?id=5696 + */ + if ($zthis->ErrorNo()<>0) return 0; - $cnt = $zthis->GetOne("select count(*) from $table where $where"); - if ($cnt > 0) return 1; // record already exists - } else { - if (($zthis->Affected_Rows()>0)) return 1; - } - } else - return 0; - } + # affected_rows == 0 if update field values identical to old values + # for mysql - which is silly. - // print "<p>Error=".$this->ErrorNo().'<p>'; - $first = true; - foreach($fieldArray as $k => $v) { - if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col - // Add Quote around Column Name - if ($first) { - $first = false; - $iCols = sprintf('%s%s%s',$zthis->nameQuote,$k,$zthis->nameQuote); - $iVals = "$v"; + $cnt = $zthis->GetOne("select count(*) from $table where $where"); + if ($cnt > 0) return 1; // record already exists } else { - $iCols .= sprintf(',%s%s%s',$zthis->nameQuote,$k,$zthis->nameQuote); - $iVals .= ",$v"; + if (($zthis->Affected_Rows()>0)) return 1; } + } else + return 0; + } + +// print "<p>Error=".$this->ErrorNo().'<p>'; + $first = true; + foreach($fieldArray as $k => $v) { + if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col + // Add Quote around Column Name + if ($first) { + $first = false; + $iCols = sprintf('%s%s%s',$zthis->nameQuote,$k,$zthis->nameQuote); + $iVals = "$v"; + } else { + $iCols .= sprintf(',%s%s%s',$zthis->nameQuote,$k,$zthis->nameQuote); + $iVals .= ",$v"; } - $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; - $rs = $zthis->Execute($insert); - return ($rs) ? 2 : 0; + } + $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; + $rs = $zthis->Execute($insert); + return ($rs) ? 2 : 0; } // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM |
