Skip to content

fix variable names of the proposed solution#21

Open
mimoun-ellebbar wants to merge 2 commits intomainfrom
fix/exercise-solution-bug
Open

fix variable names of the proposed solution#21
mimoun-ellebbar wants to merge 2 commits intomainfrom
fix/exercise-solution-bug

Conversation

@mimoun-ellebbar
Copy link

Pre-flight Checklist

  • Are all the features in this PR tested?
  • Have other features this PR touches also been tested?
  • Has the code been formatted for consistency and readability?
  • Did you also update related documentation and tooling, such as .readme or tests?

Overview

There’s a bug in the into queries exercise solution. A line of code converts an input variable from an array into a string, but later the solution tries to use that same variable as if it were still an array. Since the original data gets overwritten, the program will crash

Context

Requirements addressed:

  • Rename the variable created after converting the array to a string, instead of overwriting the original input.
  • Update all usage points to reference the new output variable.
  • Preserve the original input type to prevent incorrect usage and runtime errors.

Screenshots

image To: image

@paulj3 paulj3 requested a review from mmcev106 February 16, 2026 22:17
@mmcev106 mmcev106 requested review from ChemiKyle and removed request for mmcev106 February 17, 2026 15:21
@mmcev106
Copy link
Contributor

@ChemiKyle, would you like to review this since you wrote it?

@ChemiKyle
Copy link
Contributor

Good catch @mimoun-ellebbar! Your proposed solution works for n = 1, I added a suggestion to expand support to more than 1 user. 2 infinite improvements in 2 commits!

@mimoun-ellebbar
Copy link
Author

Appreciate it @ChemiKyle, but the function logic still unchanged, i just wrangled the variable names so the function would continue to use each variable's data for the right context

Copy link
Contributor

@ChemiKyle ChemiKyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to approve once these 2 changes are committed.

@mimoun-ellebbar we typically expect DataCore team members to merge their own PRs after approval (as a reviewer, you'll usually only merge PR from a collaborator without write access to a repository).

WHERE username IN (' . implode(',', $questionMarks) . ')';

$result = $this->query($sql, [$new_value, $users]);
$result = $this->query($sql, [$new_value, $usernames_data]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$result = $this->query($sql, [$new_value, $usernames_data]);
$result = $this->query($sql, [$new_value, $users]);

This needs to be the user array otherwise it only works when only a single user is altered.

Copy link
Author

@mimoun-ellebbar mimoun-ellebbar Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see what you are saying, but in that case the join/implode logic would be unnecessary, also the $users param would not get accepted, i guess the best approach here, based on source code:

  1. get rid of join logic for usernames:
    $usernames_data = implode('", "', $users);
  2. change the update to this :

$params = array_merge([$new_value], $users); $result = $this->query($sql, $params);

Co-authored-by: Kyle Chesney <kyle.2493@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments