Drupal sequences

Events happening in the community are now at Drupal community events on www.drupal.org.
mike_gie12's picture

Hi! Just want to share this to everyone. I don't know if this can be considered a lesson here but it sure was a lesson to me. Drupal has its own sequence for adding new entries (like menus, nodes, terms, vocabularies, and etc...). Some of its core module triggers 'db_next_id' to provide the next key before inserting a new record. In some cases, it is not really advisable to just do a backdoor insert as it might screw up the current sequence. Make sure to always check the 'sequences' table before doing some magic :P Just a warning! (It knocked me when I was trying to insert a menu after installing internationalization)

mike_gie.

Comments

As a rule of thumb, do not

Jhef.Vicedo's picture

As a rule of thumb, do not modify data directly on the database if it is core related. Always use the Drupal API.

Yea.. hehe! I got impatient

mike_gie12's picture

Yea.. hehe! I got impatient so I took it for granted :) bad experience...

Drupal 6 handles it differently

IncrediblyKenzi's picture

Note that the sequences table has been removed in Drupal 6 in favor of auto_increment IDs. Use db_last_insert_id() (I think that's what it's called) instead of db_next_id().

-=Aaron

Sometimes it's just a lot

chronnus's picture

Sometimes it's just a lot quicker running a mysql query, hehe. I've been in this situation a few times too.

Philippines

Group organizers

Group categories

Post category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week