Overview

Packages

  • objSQL

Documentation

  • objSQL Connection
  • objSQL Error Handling
  • General Queries
  • Prepared Statements
  • Transactions
  • Resultset Methods
  • Helper Method - Select Query
  • Helper Method - Update Query
  • Helper Method - Insert Query
  • Helper Method - Delete Query
  • Helper Method - Paging Query
  • Helper Method - Row Count Query
  • Utility Methods
  • Firebird Notes

Classes

  • cubrid_connection
  • cubrid_prepare
  • cubrid_resultset
  • cubrid_statement
  • cubrid_transaction
  • firebird_connection
  • firebird_prepare
  • firebird_resultset
  • firebird_statement
  • firebird_transaction
  • mysql_connection
  • mysql_prepare
  • mysql_resultset
  • mysql_statement
  • mysql_transaction
  • obj_access
  • objSQL
  • pdo_connection
  • pdo_prepare
  • pdo_resultset
  • pdo_statement
  • pdo_transaction
  • pgsql_connection
  • pgsql_prepare
  • pgsql_resultset
  • pgsql_statement
  • pgsql_transaction
  • sqlite3_connection
  • sqlite3_prepare
  • sqlite3_resultset
  • sqlite3_statement
  • sqlite3_transaction
  • sqlsrv_connection
  • sqlsrv_prepare
  • sqlsrv_resultset
  • sqlsrv_statement
  • sqlsrv_transaction
  • Overview
  • Package
  • Class
  • Tree

objSQL Firebird Notes

The Firebird database server does not have native functionality to create an ID column with an autoincrementing integer datatype for insert queries.

  • Firebird uses a Generator to autoincrement an ID field and requires that you retrieve the Generator client-side before an insert.
  • objSQL does not support Generators but you can create a Sequence and a Trigger that will perform as an autoincrementing ID field when you create a new table.

<?php

try
{
    
$table = 'CREATE TABLE mytable (ID INTEGER NOT NULL PRIMARY KEY, 
                                    FIELD_1 VARCHAR(20) NOT NULL, 
                                    FIELD_2 VARCHAR(20) NOT NULL)'
;
                                    
    
$seq = 'CREATE SEQUENCE GEN_MYTABLE_ID';
    
    
$trigger = 'CREATE TRIGGER TRIG_MYTABLE FOR mytable
                ACTIVE BEFORE INSERT POSITION 0
                AS
                BEGIN
                IF (NEW.ID IS NULL) THEN
                NEW.ID = GEN_ID(GEN_MYTABLE_ID,1);
                END'
;
    
    
$dbh->obj_query( $table );
    
$dbh->obj_query( $seq );
    
$dbh->obj_query( $trigger );

    if ( 
$dbh->obj_error() )
        throw new 
Exception( $dbh->obj_error_message() );

}
catch ( 
Exception $e ) 
{
    
//log error and/or redirect user to error page
} 

?>   

objSQL 3.3.0 API documentation generated by ApiGen 2.8.0

Documentation licensed under a Creative Commons Attribution 3.0 Unported License.