0

In this code i want to incerment the value by 4 and not by one . How Can i do it ?

    select_id' => array(
          'description' => 'TODO: please describe this field!',
          'type' => 'serial',
          'not null' => TRUE,
       ),
2
  • it would be helpful to know where this code was intended for Commented Dec 16, 2013 at 19:31
  • Sure its for unit (phpunit) testing using a separate test database in Drupal7 . This is a few lines of my .install file
    – Nuk
    Commented Dec 16, 2013 at 20:25

1 Answer 1

2

Auto-incrementing by a value other than one is not an easy task. Drupal's Schema API allows you to supply the mysql_suffix property to supply mysql specific properties as explained in this comment.

The problem is that there is no mysql TABLE CREATE option which allows you to change the auto increment amount. There is a MySQL variable auto_increment_increment but it can only be set globally.

In this similar question a solution has been posted using MySQL triggers. AFAIK this is the best SQL solution that exists.

The best solution would probably to find a way to not need to auto_increment with a value other than one or use an INTEGER type and do the incrementation manually through PHP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.