Introduction - Sequences

Introduction - Sequences – Database sequences

Description

Sequences are a way of offering unique IDs for data rows. If you do most of your work with e.g. MySQL, think of sequences as another way of doing AUTO_INCREMENT. It's quite simple, first you request an ID, and then you insert that value in the ID field of the new row you're creating. You can have more than one sequence for all your tables, just be sure that you always use the same sequence for any particular table. To get the value of this unique ID use nextId() , if a sequence doesn't exists, it will be created automaticlly.

Using a sequence

<?php
...
$id $db->nextId('mySequence');
// Use the ID in your INSERT query
$res $db->query("INSERT INTO myTable (id,text) VALUES ($id,'foo')");
...
?>
Fetching rows from the query (Previous) Prepare & Execute/ExecuteMultiple (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.