The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End What is stmt_init() Re: What is stmt_init()


It’s for using Mysql prepared statements. Basically you can define a statement like "SELECT * FROM people WHERE lastname LIKE ?" and then specify parameters which are represented by ? in your statement.

This has 2 chief benefits. FIrstly you prepare the statement once but you can execute it many times, changing the parameters each time. This can be handy if you have a lot of INSERT statements to execute for instance. Also, it helps to prevent against SQL injection attacks because you aren’t concatenating parameters with the SQL statement as it’s done by the server instead.

I should point out it’s only available with the mysqli driver. Perhaps a future tutorial….