php doctrine 使用,php – 在Symfony中使用Doctrine创建表

MySQL中创建了“motor”DB之后,我使用以下命令在Symfony中配置了数据库:

$php symfony configure:database "mysql:host=localhost;dbname=motor" root

在appname / config / doctrine /下我有一个schema.yml文件.

在这个文件中我定义了下表:

Car:

actAs: { Timestampable: ~ }

columns:

brand: { type: string(255), notnull: true }

model: { type: string(255), notnull: true }

version: { type: string(255), notnull: true }

url: { type: string(255), notnull: true }

year: { type: string(4), notnull: true }

info: { type: string(10000), notnull: true }

updated_at: { type: timestamp, notnull: true }

created_at: { type: timestamp, notnull: true }

然后我执行了命令:

$php symfony doctrine:build --model

这给了我以下输出:

>> doctrine generating model classes

>> file+ /tmp/doctrine_schema_57936.yml

>> tokens /home/username/webapps/www/appname/lib/model/doctrine/CarTable.class.php

>> tokens /home/username/webapps/www/appname/lib/model/doctrine/Car.class.php

>> tokens /home/username/webapps/www/appname/lib/model/doctrine/base/BaseCar.class.php

>> autoload Resetting application autoloaders

>> file- /home/username/webapps/www/appname/cache/frontend/dev/config/config_autoload.yml.php

之后我继续用这个命令生成sql:

$php symfony doctrine:build --sql

输出是:

>> doctrine generating model classes

>> file+ /tmp/doctrine_schema_89541.yml

>> tokens /home/username/webapps/www/motor/lib/model/doctrine/base/BaseCar.class.php

>> autoload Resetting application autoloaders

>> file- /home/username/webapps/www/motor/cache/frontend/dev/config/config_autoload.yml.php

>> doctrine generating sql for models

>> doctrine Generated SQL successfully for models

但是在appname / data / sql /下生成的schema.sql文件为空.

所以这个命令$php symfony doctrine:insert-sql,没有在我的DB中生成任何表.但是它给出了一个成功的消息输出:

>> doctrine creating tables

>> doctrine created tables successfully

命令$php symfony doctrine:build –all,也没用.

知道我可能做错了吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值