Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8385607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:42:52+00:00 2026-06-09T17:42:52+00:00

The drupal database layer api says about db_query Do not use this function for

  • 0

The drupal database layer api says about db_query

Do not use this function for INSERT, UPDATE, or DELETE queries. Those should be handled via db_insert(), db_update() and db_delete() respectively.
(source)

I think this is said for other database layers as well. Does anybody know why? Is it unsafe, inefficient, etc.?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:42:54+00:00Added an answer on June 9, 2026 at 5:42 pm

    It’s just convention as far as I know. Certainly there’s no technical problem with running an INSERT/UPDATE through db_query(); all it does is run a vanilla SQL query against the database so it will definitely work.

    I’d imagine the documentation is simply pointing out that there are dedicated functions for those operations, and that those should be preferred to running an SQL INSERT etc. directly.

    ‘Structured’ queries (i.e. those using db_select(), db_insert(), db_update() and db_merge()) will also get the added benefit of being run through hook_query_alter() before they’re executed, meaning other parts of the system can alter them as required. You don’t get that same functionality when using db_query().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to insert the node manually to drupal database using mysql query. i
I use Drupal with CiviCRM for our nonprofit's public site and CRM database, and
I am trying to create a table in Drupal database using hook_schema function but
I have duplicated Drupal files and database in order to not work on production
I'm using the script from this site to migrate a Drupal database to WordPress.
I have a bit of a dilemma here. I have a drupal 7 database
I was just looking at the MySql database created by drupal after I installed
Drupal is giving me an error message which says : An illegal choice has
I have a drupal database where the node table is full of profiles. The
I'm working on a mysql query in a Drupal database that pulls together users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.