[keyword] database

Drupal7 Database API: Insert, Update, Delete and Merge queries

Before examining the specific db_insert, db_update, db_merge options, it is worth noting that
drupal_write_record($table, &$record, $primary_keys = array()) 'Saves (inserts or updates) a record to the database.', and may handle a lot of cases easily, but:
Do not use drupal_write_record() within hook_update_N() functions, since the database schema cannot be relied upon when a user is running a series of updates. Instead, use db_insert() or db_update() to save the record.

Drupal7 Database API: select (readonly) queries and processing the results

On db_query():

Use this function for SELECT queries if it is just a simple query string. If the caller or other modules need to change the query, use db_select() instead.

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

From Dynamic queries:

Drupal7 entities, bundles, and fields

Some of the information in this zone combines aspects of the core Drupal7 entity and field handling and the contributed Entity API extensions, please be aware of this distinction when reading the references.
Subscribe to RSS - database