与数据库同步的基于PHP的数据库模型? [英] PHP-based database models that sync with database?

查看:104
本文介绍了与数据库同步的基于PHP的数据库模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Django模型真的很棒,因为您可以直接在代码中定义所有模型/表,然后将其与数据库同步。这样,当您更新生产服务器时,只需运行迁移/同步脚本,您就不会忘记更新任何表。

Django models are really cool because you define all your models/tables right in the code, and then sync it with the database. That way when you go to update your production server, you just run the migration/sync script and you can't forget to update any tables.

我要的项目现在工作的不是基于Django或Python的,它是用PHP编写的,并且所有查询都是用直接的SQL编写的(没有ORM)。每次进行更改时,我们都有许多数据库需要更新。现在,我们基本上是在复制和粘贴我们的SQL脚本,并在需要运行它们的任何地方运行它们,或者如果有很大的变化,则可以使用脚本。但是,问题是,有时我们忘记了包含一些SQL。

The project I'm working on now though isn't Django or Python-based, it's written in PHP, and all the queries are written in straight SQL (no ORM). We've got many databases that need to be updated every time we make a change. Right now we're basically copying and pasting our SQL scripts and running them where-ever they need to be ran, or if it's a big change, we might use a script. The problem though, is that sometimes we forget to include some SQL.

但是,如果我们有基于代码的解决方案,那么它将自动通过我们的签入推动,我们不能忘记运行它。所以...我正在寻找一种解决方案,可以让我们用PHP定义所有模型,但是让我们继续编写简单的SQL而无需使用ORM(项目已有10年的历史,实现起来将耗费大量精力一个ORM)。

If, however, we had a code-based solution, then it would automatically get checked in with our pushes, and we couldn't forget to run it. So... I'm looking for a solution that will let us define all our models in PHP, but let us continue to write straight SQL without the use of an ORM (project is 10 years old, would be too much work to implement an ORM right now). Would be nice if it could convert our existing DB into PHP models too.

是否存在针对此的现有解决方案?

Are there an existing solutions for this?

推荐答案

这可能要花你钱,但这是我们在旧项目中使用的。

This might cost you but this is what we use for old projects.

SQLYog


http://www.databasejournal.com/features/mysql/article.php/1584401/同步-您的MySQL-数据库-使用免费的MySQL-管理工具--- SQLyog.htm

DBDeploy -开源


http://dbdeploy.com/

PHING& DBDeploy -操作方法


http://www.davedevelopment.co.uk/2008/04/14/how-to -sing-database-migrations-with-phing-and-dbdeploy /

这篇关于与数据库同步的基于PHP的数据库模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆