Database

Database

创建

无论你在哪找到”booklink”都要用你的项目的名字来代替他。用下面例子的结构。

  • Create app/installers/booklink_installer.php.
  • 在里面写上数据表的定义。
<?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');
    }
 }
 
?>

简单是一件好事… 列的类型选择如下

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

你使用的数据库的任何类型在这里是得到支持的,例如MYsql的varchar 或者 smallint 。 但是有一个警告:不要在MySql中使用tinyint,因为那样的话,他会被当作boolean类型。

http://phplens.com/lens/adodb/docs-datadict.htm看一下如何定制列的选择。

  • 输入./script/migrate Booklink install来建立一个文件。
  • 如果你使用Subversion:
    • 输入svn status
    • 每一行的开始都有”?”,输入svn add <path>
    • 输入svn commit -m '建立books table' . 任何一个评论也许都会在-m之后。
 
database_cn.txt · Last modified: 2008/07/08 10:31 by liyh
 

The Akelos Framework was created by Bermi Ferrer and other contributors.
Potions of the code and documentation have been ported from Ruby on Rails.

The Akelos Framework is released under the LGPL license.

"Akelos", "Akelos Framework", and the Akelos logo are trademarks of Bermi Labs All rights reserved.

Wiki driven by DokuWiki