手工编写CakePHP模式

CakeSchema类是基类的所有数据库模式。每一个模式类可以生成一组表。模式shell控制台类SchemaShell lib /蛋糕/控制台命令目录中的解释命令行,和基地模式类可以从数据库读取,或者生成数据库表。
CakeSchema现在可以定位,读写模式文件的插件。SchemaShell也暴露了这个功能。
CakeSchema还支持tableParameters。表参数非列特定表等信息排序,字符集,评论,和表引擎类型。每个Dbo实现tableParameters他们支持。
例子
这是一个从acl类完整的示例
/**
 * ACO - Access Control Object - Something that is wanted
 */
    public $acos = array(
        'id' => array(
            'type' => 'integer',
            'null' => false,
            'default' => null,
            'length' => 10,
            'key' => 'primary'
        ),
        'parent_id' => array(
            'type' => 'integer',
            'null' => true,
            'default' => null,
            'length' => 10
        ),
        'model' => array('type' => 'string', 'null' => true),
        'foreign_key' => array(
            'type' => 'integer',
            'null' => true,
            'default' => null,
            'length' => 10
        ),
        'alias' => array('type' => 'string', 'null' => true),
        'lft' => array(
            'type' => 'integer',
            'null' => true,
            'default' => null,
            'length' => 10
        ),
        'rght' => array(
            'type' => 'integer',
            'null' => true,
            'default' => null,
            'length' => 10
        ),
        'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
    );

每一列作为键值编码关联数组中。字段的字段名是关键,是另一个数组的值以下属性。
例子列
'id' => array(
    'type' => 'integer',
    'null' => false,
    'default' => null,
    'length' => 10,
    'key' => 'primary'
 ),

key
The primary key defines the primary key index.
null
Is the field nullable?
default
What is the default value of the field?
limit
The limit of the type of the field.
length
What is the length of the field?
type
One of the following types

integer
date
time
datetime
timestamp
boolean
biginteger
float
string
text
binary


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值