php - mysql object not converting to int -
so, have wp mysql db column following:
`update_number` = int(11) null:no, default:0
then have following php:
$rss_update = $wpdb->get_results("select update_number $table sub_id = $post_id"); if ( $rss_update ) { foreach ( $rss_update $rss_single ) { $rss_row_new = $rss_single + 1; $wpdb->update($table, array('update_number' => $rss_row_new),array( 'sub_id' => $post_id )); } }
so idea that, results sub_id = $post_id
, update_number
. (ie. "0,2,1,4,2,2")
then, each value, want increase integer value +1 , update it.
however, getting object of class stdclass not converted int
.
what doing wrong?
i think need ensure $rss_single string or int
var_dump($rss_single);exit;
$rss_update = $wpdb->get_results("select update_number $table sub_id = $post_id"); if ( $rss_update ) { foreach ( $rss_update $rss_single ) { $rss_row_new = $rss_single->update_number + 1; $wpdb->update($table, array('update_number' => $rss_row_new),array( 'sub_id' => $post_id )); } }
Comments
Post a Comment