I’m building simple query builder, and I have two questions:
-
Is it possible to secure mysql queries with normal functions to the similar level as it is done using
->execute(array(':param:' => ...? -
Is it possible to use many variables in one query, give them the same names (the ones after the semicolon), and then bind them one by one?
If I understand you correctly, you would like to know if it possible to replicate the functionality of
bindParamwith the standardmysql_*functions?Short answer is no. Please do not use the mysql functions at all, use
mysqliorPDOas these provide you with the true security when it comes toprepared statements. They can also provide much better query performance as the SQL is able to be pre-optimised for the database.You will have to define each parameter separately (even if it is the same value). You could also pass a simple array to the
execute()method call, but you do not then have the option to explicitly define the parameter types.Within your function use some thing like this: