I am going to be storing 3 pieces of info into my DB: the post_id, a trans_id, and a trans_amount (money). An example of a trans_id looks like 9q5fcs
so I reason that I should use %s
for string. How can I have the $wpdb
object store trans_amount as a double?
The post_id is simply the post id that gets returned when using the same insert function. I am using it in a another block of code before this. However, when I set its format to be inserted as %d
, it does not get inserted in the DB. The DB field is set to int(11).
Code:
global $wpdb;
$wpdb->insert( $wpdb->prefix . 'fd_transactions', array( 'trans_amount' => $amount), '%s');
$wpdb->insert( $wpdb->prefix . 'fd_transactions', array( 'post_id' => $_SESSION['fd_post_id']), '%d');
$wpdb->insert( $wpdb->prefix . 'fd_transactions', array( 'trans_id' => $trans_id), '%s');
what happen if you don’t pass data types ?