db_update without table prefix on custom table I installed Drupal with table prefixes in the database. I have my own tables in the same database which I am trying to update. I am getting an error because Drupal is automatically adding the prefix "drupal_" to the table I specified.

$key_cached_update = db_update('my_table')
  -&gt;fields(array('key_cached' =&gt; $apikeyinfo-&gt;result-&gt;key['expires'],))
  -&gt;condition('keyid', $row-&gt;keyid, '&gt;=')
  -&gt;execute();



  Base table or view not found: 1146 Table 'drupal_my_table' doesn't exist


I don't have problems with db_query to read the database.
In your settings.php file where you have prefix set in the $databases array. Change this

'prefix' =&gt; 'drupal_',


to this

'prefix' =&gt; array(
  'default' =&gt; 'drupal_',
  'my_table' =&gt; '',
),


If you want a more wildcard like way to do this you can set the target. So lets say this is what your $databases array looks like inside settings.php

$databases = array (
  'default' =&gt; array (
    'default' =&gt; array (
      'database' =&gt; 'd7',
      'username' =&gt; 'root',
      'password' =&gt; '',
      'host' =&gt; NULL,
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; 'drupal_',
    ),
  ),
);


Change it to this, where everything is the same except the prefix is empty.

$databases = array (
  'default' =&gt; array (
    'default' =&gt; array (
      'database' =&gt; 'd7',
      'username' =&gt; 'root',
      'password' =&gt; '',
      'host' =&gt; NULL,
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; 'drupal_',
    ),
    'noprefix' =&gt; array (
      'database' =&gt; 'd7',
      'username' =&gt; 'root',
      'password' =&gt; '',
      'host' =&gt; NULL,
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; '',
    ),
  ),
);


Then in your function call do this

$key_cached_update = db_update('my_table', array('target' =&gt; 'noprefix'))
  -&gt;fields(array('key_cached' =&gt; $apikeyinfo-&gt;result-&gt;key['expires'],))
  -&gt;condition('keyid', $row-&gt;keyid, '&gt;=')
  -&gt;execute();