Loading ...
Sorry, an error occurred while loading the content.

Auto-increment and primary key support

Expand Messages
  • Manuel Lemos
    Hello, After a long time without significant enhancements to Metabase, I am finally adding support to database schema features like auto-increment fields and
    Message 1 of 1 , Jul 31, 2005

      After a long time without significant enhancements to Metabase, I am
      finally adding support to database schema features like auto-increment
      fields and primary keys. Future versions of Metastorage will generate
      code that takes advantage of these features.

      Currently the new Metabase version is in alpha stage as the support for
      these features is not completely done. Here is the status:

      - autoincrement is a new option of the schema of table fields. It
      automatically expands to integer, notnull, default 0 and primary key.

      - There are two new functions in the API GetNextKey and GetInsertedKey.
      GetNextKey determines what to put in an insert statement in the place of
      the value an auto-increment field. GetInsertedKey retrieves the last
      inserted value in autoincrement field. These functions are run before
      and after an insert query respectively.

      - primarykey is a new section of table schema definition. The definition
      is similar to indexes but you can only have one primary key per table.

      - These features are implemented in the drivers for MySQL, PostgreSQL
      and Oracle. If you have access to other databases like Microsoft SQL
      server, Interbase, Informix, SQLite, Access/ODBC, mini-SQL, please let
      me know because currently I am not able to test the new features in all
      these databases.

      - Altering tables with primary keys or autoincrement fields is not yet

      - There is a new database manager API function named
      CreateDetailedTable. This is an extension of the CreateTable function to
      allow for creation of tables with primary keys and other features in the
      future. It supports a check mode that lets the schema manager know if
      the described table can be created by the database driver.

      - The schema manager now performs a safety check when installing or
      altering databases with new tables. If it is not possible to install a
      table because the current driver does not support some features, nothing
      is changed in the database and the schema manager will return an
      explanatory error message.

      - Schema reverse engineering of database tables with auto-increment
      fields or primary keys is not yet implemented.

      - The driver test suite has now a new test named autoincrement that
      tries to insert a few records in a new table with an autoincrement field
      and verifies if it worked correctly. You may look into the
      driver_test.php script for how auto-increment support works.

      - There will be a new function to set a value of a prepared query to the
      next auto-increment value of a table. This is not yet implemented but of
      course will only work with insert queries.

      These changes are available in CVS. You may find instructions on how to
      obtain access to the CVS server or a download daily snapshots from here:


      Please test these changes looking and running the driver_test.php script
      and provide your feedback.


      Manuel Lemos

      PHP Classes - Free ready to use OOP components written in PHP

      PHP Reviews - Reviews of PHP books and other products

      Metastorage - Data object relational mapping layer generator
    Your message has been successfully submitted and would be delivered to recipients shortly.