I verified that a query works. If I try to contain a version of it in a function, it doesn't seem to work. Here is the query on its own; the verification of its functionality comes from the echo in the last line:
$stmt = $conn->prepare('SELECT * FROM ObjectTable WHERE RowNum = ?');
$stmt->execute([$objecttablerow]);
while ($row = $stmt->fetch())
{
$objectformout = "${row['ObjectForm']}";
}
echo $objectformout;
Here is my attempt to contain that query in a function; I was able to independently verify that $objecttablerow contains the expected integer value that a simple function can at least echo:
function verbalize_object($vo_input) {
$objectformout = "";
$stmt = $conn->prepare('SELECT * FROM ObjectTable WHERE RowNum = ?');
$stmt->execute([$vo_input]);
while ($row = $stmt->fetch())
{
$objectformout = "${row['ObjectForm']}";
}
return $objectformout;
}
echo verbalize_object($objecttablerow);
source https://stackoverflow.com/questions/70146168/how-can-i-contain-a-pdo-query-in-a-php-function
Comments
Post a Comment