I want to retrieve the values of NEW_COLUMN_1
and NEW_COLUMN_2
columns from the database, using distinct CR numbers from the NUMBER
column in the following function below:
function retrieveDistinctFilePaths(array $distinctCRNumbers, $database)
{
$filePaths = [];
echo "<pre>"; print_r($distinctCRNumbers); echo "</pre>"; // Line A
foreach ($distinctCRNumbers as $crNumber) {
$query = "
SELECT
NEW_COLUMN_1,
NEW_COLUMN_2
FROM
your_table_name
WHERE
NUMBER = '$crNumber'";
// Execute the query and fetch results from the database
$database->executeStatement($query);
// Fetch the row from the result
$row = $database->fetchRow();
if ($row) {
$filePaths[$crNumber] = [
'NEW_COLUMN_1' => $row['NEW_COLUMN_1'],
'NEW_COLUMN_2' => $row['NEW_COLUMN_2']
];
}
}
echo "<pre>"; print_r($filePaths); echo "</pre>"; // Line Y
return $filePaths;
}
Line A in the function above prints the following:
Array
(
[0] => AUTH-GOOD-MORNING
[1] => GOOD-MORNING
)
Line Z in the function above outputs (prints) the following, as shown below. The problem with the output from Line Z is that it doesn't print the result based on 'GOOD-MORNING
' array value from Line A.
Array
(
[AUTH-GOOD-MORNING] => Array
(
[0] => Array
(
[NEW_COLUMN_1] =>
[NEW_COLUMN_2] =>
)
)
)
Problem Statement: I am wondering what changes I need to make in the function above so that Line Z prints values based on both array values at Line A.