from php manual:
odbc_exec — Prepare and execute an SQL statement
odbc_execute — Execute a prepared statement
which is prepared by odbc_prepare
so what is the different? why not to use odbc_exec directly?
If you want to execute the same statement multiple times with different parameters, then you prepare it once, and execute the prepared statement multiple times. Some RDBMS' will compile the statement when you prepare it, and this saves time when you execute it. This is useful when you have a loop executing the same query inside the loop with different parameters.
For example:
$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']));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With