Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improced performance in database changing while loops with foreach

  • Loading branch information...
commit 0adc0cf3b543d534351f487ffb482ede7b1bd0e5 1 parent ba4fba3
unknown authored
Showing with 4 additions and 7 deletions.
  1. +4 −7 catalog/includes/functions/database.php
View
11 catalog/includes/functions/database.php
@@ -52,15 +52,13 @@ function tep_db_query($query, $link = 'db_link') {
}
function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {
- reset($data);
if ($action == 'insert') {
$query = 'insert into ' . $table . ' (';
- while (list($columns, ) = each($data)) {
+ foreach($data as $columns) {
$query .= $columns . ', ';
}
$query = substr($query, 0, -2) . ') values (';
- reset($data);
- while (list(, $value) = each($data)) {
+ foreach($data as $value) {
switch ((string)$value) {
case 'now()':
$query .= 'now(), ';
@@ -76,7 +74,7 @@ function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $li
$query = substr($query, 0, -2) . ')';
} elseif ($action == 'update') {
$query = 'update ' . $table . ' set ';
- while (list($columns, $value) = each($data)) {
+ foreach($data as $columns => $value) {
switch ((string)$value) {
case 'now()':
$query .= $columns . ' = now(), ';
@@ -141,8 +139,7 @@ function tep_db_prepare_input($string) {
if (is_string($string)) {
return trim(tep_sanitize_string(stripslashes($string)));
} elseif (is_array($string)) {
- reset($string);
- while (list($key, $value) = each($string)) {
+ foreach($string as $key => $value) {
$string[$key] = tep_db_prepare_input($value);
}
return $string;
Please sign in to comment.
Something went wrong with that request. Please try again.