I am looking for a way to initial our application quickly with current database schema which is defined and seed data to the database in zendframework 2. This has been done quite well in the modern web framework like rails, play!, you name it but I don't know if it's existed in zf2. I don't find any official documentation about this :)
问问题
217 次
1 回答
1
使用 Phing 完成该任务。初始化(安装)您的应用程序不应由应用程序本身完成,而应由 Phing 等外部代理完成。
这是一个示例 phing 目标,说明如何安装数据库并使用初始数据填充它:
<target name="recreate-db">
<echo message="[Data] Drop and recreate database..." />
<pdosqlexec
url="mysql:host=${db.project.host};dbname=${db.project.dbname}"
userid="${db.project.username}"
password="${db.project.password}"
onerror="abort">
DROP DATABASE IF EXISTS `${db.project.dbname}`;
CREATE DATABASE `${db.project.dbname}`;
</pdosqlexec>
<echo message="[Data] Populate database with schema and start-data ..." />
<pdosqlexec
url="mysql:host=${db.project.host};dbname=${db.project.dbname}"
userid="${db.project.username}"
password="${db.project.password}"
onerror="abort">
<transaction src="${basePath}/db-versioning/schema.sql" />
<transaction src="${basePath}/db-versioning/start-data.sql" />
</pdosqlexec>
</target>
于 2013-02-21T22:27:08.633 回答