db_query gives PDO Exception "General error: 1366 Incorrect integer value:" when I try to update table I'm trying to execute the following SQL query 

$tweet_id_int = intval($tweet-&gt;id);
$result = db_query("INSERT INTO tweetsDB (handle,tweet,time_string,tweetid) VALUES     ('%v1','%v2','%v3','%v4')", array('%v1'=&gt;$twitter_handle,'%v2'=&gt;$tweet-&gt;text,'%v3'=&gt;$tweet-&gt;created_at,'%v4'=&gt; $tweet_id_int));


from inside a Drupal module and getting the error 

    PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '%v4' for column 'TweetID' at row 1: INSERT INTO tweetsDB (handle,tweet,time_string,tweetid) VALUES ('%v1','%v2','%v3','%v4'); Array ( [%v1] =&gt; davecohen [%v2] =&gt; taking it easy - Rosh Hashana [%v3] =&gt; Fri Sep 14 08:06:08 +0000 2007 [%v4] =&gt; 267918272 ) 


handle, tweet and time_string are VARCHAR

tweetid is BIGINT

The "TweetID" is the value I received from calling the Twitter API earlier to fetch some tweets. Twitter API returns the Tweet ID as a string, so I called 'intval' before passing it to the SQL query. If I try running the same query into the MySQL database directly via the Sequel Pro console

 INSERT INTO tweetsDB (handle,tweet,time_string,tweetid) VALUES ('davecohen','taking it easy - Rosh Hashana','Fri Sep 14 08:06:08 +0000 2007','267918272')


Then I get no problems at all.

Any help here would be MUCH appreciated!
From the Drupal API on db_query:


  Do not use this function for INSERT, UPDATE, or DELETE queries. Those should be handled via db_insert(), db_update() and db_delete() respectively.


The recommended method:

// Insert values returned from Twitter API.
$tweetsdb_id = db_insert('tweetsDB')
-&gt;fields(array(
  'handle' =&gt; $handle,
  'tweet' =&gt; $tweet,
  'time_string' =&gt;$time_string,
  'tweetid' =&gt; $id,
))
-&gt;execute();