Skip to content

Commit

Permalink
Replace each() with foreach for PHP7.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy authored and dregad committed Nov 25, 2017
1 parent 7a25315 commit d9cc6c6
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion adodb-datadict.inc.php
Expand Up @@ -520,7 +520,7 @@ function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
list($lines,$pkey,$idxs) = $this->_GenFields($flds);
// genfields can return FALSE at times
if ($lines == null) $lines = array();
list(,$first) = each($lines);
$first = current($lines);
list(,$column_def) = preg_split("/[\t ]+/",$first,2);
}
return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));
Expand Down
2 changes: 1 addition & 1 deletion adodb-error.inc.php
Expand Up @@ -115,7 +115,7 @@ function adodb_error_pg($errormsg)
'could not serialize access due to' => DB_ERROR_SERIALIZATION_FAILURE
);
reset($error_regexps);
while (list($regexp,$code) = each($error_regexps)) {
foreach ($error_regexps as $regexp => $code) {
if (preg_match("/$regexp/mi", $errormsg)) {
return $code;
}
Expand Down
3 changes: 1 addition & 2 deletions adodb.inc.php
Expand Up @@ -1190,8 +1190,7 @@ public function Execute($sql, $inputarr = false) {

foreach($inputarr as $arr) {
$sql = ''; $i = 0;
//Use each() instead of foreach to reduce memory usage -mikefedyk
while(list(, $v) = each($arr)) {
foreach ($arr as $v) {
$sql .= $sqlarr[$i];
// from Ron Baldwin <ron.baldwin#sourceprose.com>
// Only quote string types
Expand Down
2 changes: 1 addition & 1 deletion drivers/adodb-ado.inc.php
Expand Up @@ -225,7 +225,7 @@ function _query($sql,$inputarr=false)

// Map by http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthcreateparam.asp
// Check issue http://bugs.php.net/bug.php?id=40664 !!!
while(list(, $val) = each($inputarr)) {
foreach ($inputarr as $val) {
$type = gettype($val);
$len=strlen($val);
if ($type == 'boolean')
Expand Down
2 changes: 1 addition & 1 deletion drivers/adodb-ado5.inc.php
Expand Up @@ -248,7 +248,7 @@ function _query($sql,$inputarr=false)
$oCmd->CommandText = $sql;
$oCmd->CommandType = 1;

while(list(, $val) = each($inputarr)) {
foreach ($inputarr as $val) {
$type = gettype($val);
$len=strlen($val);
if ($type == 'boolean')
Expand Down
6 changes: 3 additions & 3 deletions drivers/adodb-text.inc.php
Expand Up @@ -205,7 +205,7 @@ function _query($sql,$input_arr,$eval=false)
$where_arr = array();

reset($this->_origarray);
while (list($k_arr,$arr) = each($this->_origarray)) {
foreach ($this->_origarray as $arr) {

if ($i == 0 && $this->_skiprow1)
$where_arr[] = $arr;
Expand Down Expand Up @@ -243,7 +243,7 @@ function _query($sql,$input_arr,$eval=false)
$i = 0;
$n = '';
reset($this->_colnames);
while (list($k_n,$n) = each($this->_colnames)) {
foreach ($this->_colnames as $n) {

if ($col == strtoupper(trim($n))) break;
$i += 1;
Expand Down Expand Up @@ -298,7 +298,7 @@ function _query($sql,$input_arr,$eval=false)
if ($at == 0) {
$i = 0;
reset($projnames);
while (list($k_n,$n) = each($projnames)) {
foreach ($projnames as $n) {
if (strtoupper(trim($n)) == $col) {
$at = $i+1;
break;
Expand Down
3 changes: 1 addition & 2 deletions replicate/adodb-replicate.inc.php
Expand Up @@ -794,8 +794,7 @@ function ReplicateData($table, $desttable = '', $uniqflds = array(), $where = '
if ($useQmark) {
$sql = ''; $i = 0;
$arr = array_reverse($rs->fields);
//Use each() instead of foreach to reduce memory usage -mikefedyk
while(list(, $v) = each($arr)) {
foreach ($arr as $v) {
$sql .= $sqlarr[$i];
// from Ron Baldwin <ron.baldwin#sourceprose.com>
// Only quote string types
Expand Down
2 changes: 1 addition & 1 deletion toexport.inc.php
Expand Up @@ -77,7 +77,7 @@ function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote =
reset($fieldTypes);
$i = 0;
$elements = array();
while(list(,$o) = each($fieldTypes)) {
foreach ($fieldTypes as $o) {

$v = ($o) ? $o->name : 'Field'.($i++);
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
Expand Down

0 comments on commit d9cc6c6

Please sign in to comment.