ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:portable_sql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
v5:userguide:portable_sql [2016/02/27 18:42] mnewnhamv5:userguide:portable_sql [2016/03/13 23:52] – [Inserting Records] mnewnham
Line 98: Line 98:
 ===== Inserting Records ===== ===== Inserting Records =====
  
-When you create records, you need to generate unique id's for each record. There are two common techniques: (1) auto-incrementing columns and (2) sequences.+When you create records, you need to generate unique id's for each record. There are two common techniques:  
 +  * Auto-increment columns 
 +  * Sequences
  
-Auto-incrementing columns are not supported by some databases, so for portability, you have little choice but to use sequences. Sequences are special functions that return a unique incrementing number every time you call it, suitable to be used as database keys. In ADOdb, we use the [[v5:reference:connection:genid|genId()]] function. It has takes a parameter, the sequence name. Different tables can have different sequences.+Auto-increment columns are not supported by some databases, so for portability, you have little choice but to use sequences. Sequences are special functions that return a unique incrementing number every time you call it, suitable to be used as database keys. In ADOdb, we use the [[v5:reference:connection:genid|genId()]] function. It has takes a parameter, the sequence name.  
 + 
 +Different tables can have different sequences.
  
 <code php> <code php>
 $id = $connection->GenID('sequence_name'); $id = $connection->GenID('sequence_name');
 $connection->Execute("insert into table (id, firstname, lastname)  $connection->Execute("insert into table (id, firstname, lastname) 
-    values ($id, $firstname, $lastname)");+          values ($id, $firstname, $lastname)");
  
 </code> </code>
-For databases that do not support sequences natively, ADOdb emulates sequences by creating a table for every sequence.+For databases that do not provide native support for sequence, ADOdb provides emulation by creating a table for every sequence.
  
 ===== Binding ===== ===== Binding =====
v5/userguide/portable_sql.txt · Last modified: 2020/12/30 21:32 by peterdd