I guess the easiest way to prevent sql injection on PDO::Query which take arguments from the user is to use PDO::prepare and PDO::execute. However in my case I have an insert statement which takes a param from user. For this purpose I'm using PDO::exec. Below is not the exact code.
$db = new PDO("Connection String to connect to MSSQL");
$rowsAffected = $db->exec("Insert into MyTable (UserParam) Values($userParam)");
How can I prevent an sql injection on this?