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 8089165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:19:21+00:00 2026-06-05T19:19:21+00:00

OK, so I read about drupal_write_record , which apparently serves as a function which

  • 0

OK, so I read about drupal_write_record, which apparently serves as a function which does an insert_or_update.

However from what I’ve read, it doesn’t know by itself whether to do the insert or the update, but this is determined by the existence (or not) of the 3rd parameter: $primary_keys which defaults to array(). Is this true? Do I have to select the record first, see if exists, and then pass or not the 3rd param to drupal_write_record?

I’m asking this, because how I normally do an insert or update function is to do a select based on the primary key(s), and if the row exists, then I have to do an update, if not, an insert. Is this not the way that drupal_write_record works?

Using Drupal 7.0 by the way.

  • 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-05T19:19:22+00:00Added an answer on June 5, 2026 at 7:19 pm

    According to the documentation:

    $primary_keys: To indicate that this is a new record to be inserted, omit this argument. If this is an update, this argument specifies the primary keys’ field names. If there is only 1 field in the key, you may pass in a string; if there are multiple fields in the key, pass in an array.

    Source: drupal_write_record API documentation

    If the third parameter– $primary_keys— is an array with the field names for primary keys, then it will attempt to update an exist record. If you leave out a value $primary_keys, it will default to an empty array which means that it will insert a new record with its own unique ID.

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

Sidebar

Related Questions

I've read about it, I understand it's basic function--I'd like to know an example
Read about Server push here . I want to push data to client from
I read about the requirements of NDK programming on Windows which said we require
I read about Big-O Notation from here and had few questions on calculating the
Read about Fog: http://fog.io Does Python have anything like it? (a library for cloud
I read about structure in c++ that it can not contain instance of itself.
I read about skipList implementation in C++ and I don't understand this random function
I read about 'side effect' from this website : but still not understand why
I read about JSON from internet but still i have not got the grasp
I recently read about quicksort and was wondering whether it would be smart to

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.