Skip to content

Commit

Permalink
Foreach in the correct way on database function
Browse files Browse the repository at this point in the history
  • Loading branch information
acidvertigo committed Aug 17, 2011
1 parent 8e40f3a commit b26f367
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions catalog/admin/includes/functions/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $li
$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(), ';
Expand Down
4 changes: 2 additions & 2 deletions catalog/includes/functions/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $li
reset($data);
if ($action == 'insert') {
$query = 'insert into ' . $table . ' (';

while (list($columns, ) = each($data)) {
$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(), ';
Expand Down

0 comments on commit b26f367

Please sign in to comment.