I want to make sure I don't have some memory-leak and bad coding-habits. I might just be answering myself here.
This is a typical function of mine, Should I Bind a $temp in all the return cases and then return it at the end instead or is this fine?
define DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
function Resolvestuff($input) {
global $db;
if ($stmt = $db->prepare("Select Column from Table where `a` = ?")) {
$stmt->bind_param('s', $input);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($col1);
$row = $stmt->fetch();
if ($stmt->num_rows == 0) {
return "Nothing";
} else {
return $col1;
}
$stmt->free_result(); // i mean, is this even performed at some point ?
$stmt->close();
} else {
return "Nothing";
}
//Return here instead ?
}