I have a problem regarding the bind_param() function. So I know it's important to prepare and parameterize your query, but I've come to a problem.
Below is how I usually do the preparation, and it works well
function select($what, $table, $id, $age)
{
$sql = 'SELECT ' . $what . ' FROM ' . $table . ' WHERE id = ? AND age = ?';
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('ii', $id, $age);
$stmt->execute();
$result = $stmt->get_result();
return $result;
}
Now, what I want to achieve but I don't know how
function select($what, $table, $where)
{
$sql = 'SELECT ' . $what . ' FROM ' . $table . ' WHERE ' . $where;
$stmt = $mysqli->prepare($sql);
$stmt->bind_param(); #Now what?
$stmt->execute();
$result = $stmt->get_result();
return $result;
}
The called function will look like
select('*', 'tablename', 'id = 1, age = 25, height = 1.5, dob = 01/01/1990');
I can and will clarify my question if it's not clear enough already. Thank you in advance!