PHP 最容易使用的 ORM 框架是什么?

2022-01-01 00:00:00 orm php

我正在寻找 Ruby 的 PHP 活动记录.一些非常简单的事情,我只需定义我的字段,扩展基本 ORM 类,然后我就可以免费获得 ACID 操作.我应该在不编写任何代码的情况下获得默认的 getter 和 setter,但是覆盖默认的 getter 或 setter 就像使用我想要的行为声明 get$fieldName 或 set$fieldName 函数一样简单.Symphony 让你为每个对象创建大约 5 个文件,并且据我所知,所有定义的对象总是加载.什么是更好的选择?为什么更好?你能在你的答案中举出简单的例子吗?

I'm looking for Ruby's Active record for PHP. Something that is so simple that I just define my fields, extend the base ORM class, and I get ACID operations for free. I should get default getters and setters without writing any code, but overriding a default getter or setter is as easy as declaring get$fieldName or set$fieldName functions with the behavior I want. Symphony makes you create about 5 files per object, and all defined objects always load as far as I can tell. What is a better alternative? Why is it better? Can you put simple examples in your answers please?

Doctrine 是除了 Symphony 之外我还研究过的另一个 ORM.您还需要创建描述数据结构的 yaml 文件.数据库已经定义了这些东西.什么只会读取我的表 defs 而不必在任何地方生成和存储配置文件?

Doctrine is another ORM I've looked at besides symphony . There also you need to create yaml files that describe your data structures. The database already defines this stuff. What will just read my table defs without having to generate and store config files everywhere?

推荐答案

Both CodeIgniter (http://codeigniter.com/user_guide/database/active_record.html) 及其 PHP5 仅 fork Kohana (http://docs.kohanaphp.com/libraries/orm) 包含 ActiveRecord 模式的实现.

Both CodeIgniter (http://codeigniter.com/user_guide/database/active_record.html) and its PHP5 only fork Kohana (http://docs.kohanaphp.com/libraries/orm) contain implementations of the ActiveRecord pattern.

相关文章