Enhance query to include 'val' and skip empty values
Update the SQL query to fetch 'val' alongside 'user_id' and modify the logic to skip rows with empty 'val'. This ensures only relevant data is processed, improving data integrity and correctness.
This commit is contained in:
@@ -112,12 +112,16 @@ class user_key_value_pairs_o extends db
|
||||
{
|
||||
global $db;
|
||||
// Get all the users, and their customer numbers, with the given keys
|
||||
$sql = "SELECT user_id FROM $this->table WHERE var IN ('" . implode("','", $keys) . "')";
|
||||
$sql = "SELECT user_id, val FROM $this->table WHERE var IN ('" . implode("','", $keys) . "')";
|
||||
$result = $db->query($sql);
|
||||
$result = $db->fetch_all($result);
|
||||
$user_ids = [];
|
||||
// Add the user ids to the array
|
||||
foreach ( $result as $row ) {
|
||||
// Check if the value is empty
|
||||
if (empty($row['val'])) {
|
||||
continue;
|
||||
}
|
||||
$user_ids[] = (int)$row['user_id'];
|
||||
}
|
||||
// Get the customer numbers from the users table
|
||||
|
||||
Reference in New Issue
Block a user