's comment, I should also point out that by re-preparing the statement each time you go to execute it you're largely losing the value of having a prepared statement. Instead, try
ing the statement outside the loop and then executing it for each message inside the loop, passing in the appropriate set of bind values each time.