Database

Database

Creating

Replace “booklink” with your project name wherever it is found. Use the case structure in the example.

  • Create app/installers/booklink_installer.php.
  • Enter the table definitions in it.
<?php
 
  class BooklinkInstaller extends AkInstaller
  {
    function up_1(){
 
      $this->createTable('books', // The table name must be plural.
        'id,'.                    // This key must be in every table.
        'col_1 string(10),'.      // Columns have default characteristics.  
        'col_last'                // The last column does not end with a "."
      );
    }
 
    function down_1(){
      $this->dropTables('books');
    }
 }
 
?>

The column type options are

  • integer or int
  • float
  • datetime, date, timestamp, time
  • text
  • string
  • binary
  • boolean or bool

Or any column type that is supported by the database you’re using, like varchar or smallint on MySQL. One warning though: don not use tinyint on MySQL because it will be typecasted as boolean.

See http://phplens.com/lens/adodb/docs-datadict.htm to customize column options.

  • Create the file by entering ./script/migrate Booklink install.
  • If you are using Subversion:
    • Enter svn status
    • For each line beginning with a ”?”, enter svn add <path>
    • Enter svn commit -m 'create books table' . Any comment may follow -m.
 
database.txt · Last modified: 2008/02/05 19:34 by thijs