2

I have a where clause in my query like this "WHERE sth REGEXP '[0-9]{5,10}'"

when I run this query in phpmyadmin it returns all matched records but in drupal it has no result.I think it's because drupal assumes everything like "{sth}" as a table.

how can I solve this problem?

Thanks

2
  • Whilst Drupal does use braces to delimit table names, I wouldn't expect it to do this inside strings. Commented Apr 23, 2011 at 16:26
  • OK, the source seems to imply that it does. How lame. Commented Apr 23, 2011 at 16:28

1 Answer 1

4

Your theory is correct.

Curly brackets used as repetition quantifier in regexes are removed as any other curly bracket. Pass the regex as an argument to db_query() instead like this:

db_query('SELECT name from {users} WHERE std RLIKE "%s"', '[0-9]{5,10}');

(I've had to guess at the rest of your query.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.