Give the gift of Drupal. All merchandise is 50% off through 2016.
As said here db_link cannot be used with db_query.
I replace it with
$variables = db_select('variable', 'v')->fields('v', array('name'))->condition('name', db_like('openlayers_') . '%', 'LIKE')->execute()->fetchCol();
and it works fine.
This is the same for openlayers_ui and openlayers_views.