简体   繁体   English

PHP框架没有与数据库紧密耦合并使用存储过程?

[英]PHP frameworks that aren't tightly coupled to the database and work with stored procedures?

This has been coming up at work recently, and Google's been...eh, minimally useful. 最近这个问题已经出现了,谷歌已经......呃,最不实用了。

We're using Yii, but company policy is that all database access has to be done through MySQL stored procedures, which "breaks" quite a bit of Yii and renders some of its attempts at making life easier, well, irrelevant. 我们正在使用Yii,但公司的政策是所有数据库访问必须通过MySQL存储过程完成,这会“打破”相当多的Yii,并使其一些尝试使生活更轻松,更好,无关紧要。 (To be clear, the decision to require only SPs was made after Yii had been implemented.) (要明确的是,在Yii实施之后,只需要SP的决定。)

Are there any PHP frameworks out there that would work better under this limitation? 是否有任何PHP框架可以在此限制下更好地工作? We're using YiiBooster, so any other framework has to be Bootstrap-compatible or the UI/UX department will start screaming. 我们正在使用YiiBooster,因此任何其他框架必须与Bootstrap兼容,否则UI / UX部门将开始尖叫。

TLDR version: TLDR版本:

My initial impression, from Googling and searching here, is that any other PHP framework will have the exact same limitations. 我从谷歌搜索和搜索这里的初步印象是,任何其他PHP框架都将具有完全相同的限制。 Is this correct? 它是否正确?

You are correct. 你是对的。 Any other framework will also have this limitation. 任何其他框架也将具有此限制。

This is because a Framework itself is an abstraction from the underlying language. 这是因为框架本身是底层语言的抽象。 The framework abstracts the php code and the orm abstracts the storage in eg MySQL. 框架抽象了php代码,orm抽象了MySQL中的存储。

What you want is another abstraction layer between the ORM and the database 'manager'. 你想要的是ORM和数据库'manager'之间的另一个抽象层。 I'm afraid but you'll need to write your own orm or extend and orm in order to accomplish this task. 我很害怕,但你需要编写自己的orm或扩展和orm才能完成这项任务。

或者,您可以转向真正管理控制器的“微框架”,让您可以自由地以符合SP的方式对您的模型进行编码,并以符合引导程序的方式对您的视图进行编码。

Yii is extensible by its nature and does not require a DB connection to run at all. Yii本质上是可扩展的,并且根本不需要DB连接。

I suggest writing your own DataProvider class, have a look at CArrayDataProvider http://www.yiiframework.com/doc/api/1.1/CArrayDataProvider as a jumping off point. 我建议编写自己的DataProvider类,看看CArrayDataProvider http://www.yiiframework.com/doc/api/1.1/CArrayDataProvider作为跳出点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM