Toggle a column bit regardless of state

Submitted by:Jhon Brain

Date added:30 August, 2014

Category:PHP

Toggle a column bit regardless of state. Useful to change state without doing a query first to detect the state of the bit.

Tags: toggle column , change state

Code Snippet:

// simple one-liner toggles the column 'ban_enabled' bit regardless of state
$toggle_sql = "UPDATE some_table SET ban_enabled = 1 - ban_enabled WHERE item_id = '$bid' LIMIT 1";
 
 

Comments