3

I have lot of variables created in a module. Is there any wildcard when deleting variables using variable_del.

Ex1: variable_del($key . '_campaign_text_*');
Ex2: variable_del($key . '_campaign_text_%');

Will any of these workout?

  • 1
    No they won't. Wild cards don't work. You'd need to first query the DB and then loop through your results deleting them. – Jaypan Sep 27 '16 at 9:14
5

You can try db_delete but handle with caution.

Example :

db_delete('variable')
->condition('name', '_campaign_text_%','LIKE')
->execute();
cache_clear_all('variables', 'cache_bootstrap');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.