php 哪个 ORM 用于 codeigniter?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3438198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 09:46:31  来源:igfitidea点击:

Which ORM for codeigniter?

phpsqlormcodeigniter

提问by Keyo

The quote below has convinced to finally go ORM. In the past I havn't really liked ORM and wrote it off as a stupid way of doing sql. Dealing with hierarchical data in sql is a pain I don't want to deal with.

下面的引文已经说服最终走向 ORM。过去我并不是很喜欢 ORM,并认为它是一种愚蠢的执行 sql 的方式。在 sql 中处理分层数据是一种我不想处理的痛苦。

There's a reason we have these “Object-Relational Mapper” things, and it's because of a problem known as the Object-Relational Impedance Mismatch. Basically, the formal mathematical model for databases used to ensure that they stay intact follows a system of tables with rows and columns and references to other tables, while data structures in most programming languages we use today manipulate data in nested tree-like structures. It's rather like the difference between a spreadsheet and an XML document, or between a ledger and a family tree diagram. - http://zork.net/motd/nick/django/your-favorite-orm-sucks.html

我们有这些“对象-关系映射器”的东西是有原因的,这是因为一个称为对象-关系阻抗不匹配的问题。基本上,用于确保数据库保持完整的正式数学模型遵循具有行和列的表系统以及对其他表的引用,而我们今天使用的大多数编程语言中的数据结构以嵌套的树状结构操作数据。这更像是电子表格和 XML 文档之间的区别,或者分类帐和家谱图之间的区别。- http://zork.net/motd/nick/django/your-favorite-orm-sucks.html

I want something with minimal effort to setup. Most of my project are small so I don't want to spend much time defining models when I only use them for few queries.

我想要一些轻松设置的东西。我的大部分项目都很小,所以当我只将它们用于少数查询时,我不想花太多时间定义模型。

I'm using codeigniter as the php framework and MySQL as the database.

我使用 codeigniter 作为 php 框架,使用 MySQL 作为数据库。

采纳答案by musoNic80

Doctrine is brilliant and very easy to setup and use with CI. There are three ways of integrating it 1) the way described in the CI wiki 2) as a plugin 3) using hooks. I don't like option 1 as it involves messing with CI system files. Option 2 is very easy and what i currently use. Setup is described at www.phpandstuff.com. I've never tried option 3 but it sounds interesting - http://blog.medryx.org/2008/10/04/codeigniter-and-doctrine/

Doctrine 非常出色,并且非常易于设置和与 CI 一起使用。有三种集成方式 1) CI wiki 中描述的方式 2) 作为插件 3) 使用钩子。我不喜欢选项 1,因为它涉及弄乱 CI 系统文件。选项 2 非常简单,也是我目前使用的选项。www.phpandstuff.com 上介绍了设置。我从未尝试过选项 3,但听起来很有趣 - http://blog.medryx.org/2008/10/04/codeigniter-and-doctrine/

回答by tlarevo

I think you should try the DataMapper ORMwhich is written in native CI Also easy to configure and easy to use as well. I think it's better than Doctrine.

我认为您应该尝试使用本机 CI 编写的DataMapper ORM也易于配置和使用。我认为它比 Doctrine 更好。

回答by Flakron Bytyqi

Here are the ones I use

这是我使用的

  1. Doctrine

  2. DataMapper

  1. 教义

  2. 数据映射器

回答by Matthew

How about Datamapper Overzealous Edition

Datamapper Overzealous Edition怎么样?

I think that the original DataMapper (from stensi) isn't under development anymore. (Someone correct me if I'm wrong) Datamapper Overzealous Edition is easy to get working with Codeigniter.

我认为原始的 DataMapper(来自 stensi)不再处于开发阶段。(如果我错了,有人纠正我)Datamapper Overzealous Edition 很容易使用 Codeigniter。

I'm sure Doctrine works well too, but I'm not sure how easy it is to set up with Codeigniter.

我确信 Doctrine 也能很好地工作,但我不确定使用 Codeigniter 进行设置有多容易。

回答by Centurion

I would recommend

我会推荐

http://www.doctrine-project.org/, it is very popular so you will have knowledge, and will be able to use it in other framworks.

http://www.doctrine-project.org/,它非常流行,因此您将拥有知识,并且能够在其他框架中使用它。