Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/intro_to_queries/IntroQueriesModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function gatherUsers() {
}

public function alterUsers($users, $new_value) {
$users = implode('", "', $users);
$usernames_data = implode('", "', $users);
// FIXME: write and run the SQL command, log what was done

return $result;
Expand Down
6 changes: 3 additions & 3 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Read the [Method Documentation](methods/README.md). Search for the `query` funct
$sql = 'SELECT username
FROM redcap_user_information';

$result = $this->query($sql);
$result = $this->query($sql, []);

/* stop writing here */
// parse the mysqli response object into an array
Expand All @@ -329,7 +329,7 @@ Read the [Method Documentation](methods/README.md). Search for the `query` funct
}

function alterUsers($users, $new_value) {
$users = implode('", "', $users);
$usernames_data = implode('", "', $users);
// FIXME: write and run the SQL command, log what was done

$questionMarks = [];
Expand All @@ -341,7 +341,7 @@ Read the [Method Documentation](methods/README.md). Search for the `query` funct
SET allow_create_db = ?
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);


if ($result) {
// Log what was done if successful
Expand Down