If you want to execute the same statement several times with different parameters, then you prepare it once and execute the prepared statement several times. Some RDBMSs will compile an expression in its preparation, and this saves time in its execution. This is useful when you have a loop executing the same query inside a loop with different parameters.
For instance:
$stm = odbc_prepare($conn, 'INSERT INTO users (id, name, email) VALUES (?, ?, ?)'); foreach($users as $user) { $success = odbc_execute($stm, array($user['id'], $user['name'], $user['email'])); }
source share