Just a general thread for questions related to MySQL.
Here is my question, when should one use stored procedures?
I use PHP with PDO and almost always have a dynamic where clause, is it wrong to use prepared statements throughout the app instead of stored procedures, how do you even make use of a dynamic query in a stored procedure?
As an example is a query like this possible as a stored procedure:
Here is my question, when should one use stored procedures?
I use PHP with PDO and almost always have a dynamic where clause, is it wrong to use prepared statements throughout the app instead of stored procedures, how do you even make use of a dynamic query in a stored procedure?
As an example is a query like this possible as a stored procedure:
PHP:
$stmt = $dbh->prepare("SELECT * FROM users WHERE firstname = :name OR lastname = :lastname");
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
$stmt->bindParam(':lastname', $lastname, PDO::PARAM_STR);
Last edited: