And also, doing the cast inside the sql statement makes it difficult to see. It should be done, if at all, outside the query where it's obvious to anyone looking at the code that this is something that should be paid attention to.
If you're inserting a value in a database, you always, always, always use the proper escaping mechanism. No exceptions.
That's why using a library with a reliable, well-defined, easy to use escaping system is absolutely imperative.
This is an actual, serious problem which I would note in a code review, as opposed to the int thing which cannot, as far as I can can tell, ever lead to an exploit or malfunction which would have been avoided by using a named escape function in this code. If anyone can think of a specific example to prove this wrong, please say so.