I have the following code:
public function getDefinitions($wordID) {
$query = $this->dbc->prepare('SELECT * FROM definitions WHERE wordID = ?');
$query->bind_param('i', $wordID);
$query->execute();
// ...
$query->close();
return $result;
}
It would seem that this would recreate the prepared statement for each invocation. That does not seem to take advantage of the full benefit of prepared statements. Especially in the case these prepare statements were stored server side. Is that true?
If so, should I store the prepare statement (in this case as a property) to persist it between invocations. Is there a way to persist the prepared statement between requests? I assume that's essentially a stored procedure?
Currently I am using MySQLi. Please note any API difference if I were using another driver (e.g. PDO).