Can anyone explain to me how to execute a database query in Drupal 7 block? Block is not created from a module. It is created by admin. We have a PHP code filter in the content editor. There I have to execute a query.
Someone give me samples.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Documentation and examples for writing db queries in Drupal are here: Database abstraction layer.
That said, it is not recommended to use the PHP filter and enter PHP in a block. It’s less secure, trickier to maintain (no version control!) and more difficult to debug if something breaks.