How do I programmatically disable/enable a block? I have the following code but its not disbling the block. It remains active and visible on the sidebar where i have placed it.

$theme="themename";
$block="client-block-1938";
$module="modulename";
$region="right_top_box";
db_merge('block')
        -&gt;key(array('theme' =&gt; $theme, 'delta' =&gt; $block, 'module' =&gt; $module))
        -&gt;fields(
                       array(
                              'region' =&gt; $region,
                              'status' =&gt; 0,
                              'visibility' =&gt; 0,
                           )
             )
-&gt;execute();
cache_clear_all();
Use db_update.

db_update('block')
   -&gt;fields(array(
     'status' =&gt; 0,
     'weight' =&gt; -10,
     'region' =&gt; 'disabled',
   ))
   -&gt;condition('module', 'modulename')
   -&gt;condition('delta', 'modulename_delta')
   -&gt;execute();