So I have found that when using db2 sql is inside a php function it does not return any values.
It fails on DB2_PREPARE($conn, $sql2);
Where as if you execute this code outside of the function it does its job perfectly fine and returns all of the results.
Code:
function getRooms(){
$sql2 = ("SELECT * FROM WS_ASSETS_rooms");
$stmt2 = db2_prepare($conn, $sql2);
if ($stmt2) {
$result2 = db2_execute($stmt2);
if (!$result2) {
return "exec errormsg: " .db2_stmt_errormsg($stmt2);
}
while ($row = db2_fetch_array($stmt2)) {
echo "$row[1]";
}
} else {
return "exec errormsg: " .db2_stmt_errormsg($stmt2);
}
};
echo getRooms();
This returns "exec errormsg:"
and no error.