什么是对象关系映射框架? [英] What is an Object-Relational Mapping Framework?

查看:116
本文介绍了什么是对象关系映射框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说;什么是ORM框架?它有什么用?

As the title says; what is a ORM framework and what is it useful for?

推荐答案

来自维基百科 :

对象关系映射(ORM,O/RM, 和O/R映射) 是一种用于 在不兼容的数据之间转换 关系数据库中的类型系统 和面向对象的编程 语言.实际上,这会创建一个 虚拟对象数据库"可以是 从编程中使用 语言.有免费和 可用的商业软件包 执行对象关系映射, 尽管有些程序员选择 创建自己的ORM工具.

Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ORM tools.

这对于抽象化数据存储(平面文件/SQL/其他内容)以便提供可在您的代码中使用的接口非常有帮助.例如,我们可以这样做(而不是构造SQL来在users表中查找第一个用户),

It's good for abstracting the datastore (flat file / SQL / whatever) out in order to provide an interface that can be used in your code. For example, (in rails) instead of constructing SQL to find the first user in a users table, we could do this:

User.first

哪个会返回给我们用户模型的实例,并在users表中包含第一个用户的属性.

Which would return us an instance of our user model, with the attributes of the first user in the users table.

这篇关于什么是对象关系映射框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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