Web应用程序中的ORM是什么? [英] What is an ORM in a web application?

查看:80
本文介绍了Web应用程序中的ORM是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近收到服务器公司的回复,询问我们是在应用程序中使用ORM来完成筛选应用程序端的所有工作(例如Rails),还是编写大量的SQL,嵌入式函数等,从而使数据库服务器为您进行处理.

I recently got a reply from a server company asking if we are using an ORM in our application which does all the work of sifting application side (like Rails) or if we write reams of SQL, embedded functions etc which would make the database server do the processing for you.

任何人都可以解释这是什么意思.我们的Web应用程序由具有函数的PHP脚本组成,这些函数调用数据库以检索数据行,然后PHP根据需要处理这些行以将结果返回给用户.

Can anyone explain what is meant by this. Our web application is made up of PHP scripts with functions that make calls to the database to retrieve rows of data, then PHP processes these rows as needed to return results to the user.

谢谢

推荐答案

它基本上使数据库表在站点的PHP端看起来像对象,因此您可以轻松地操作数据.

It basically makes your database tables appear like objects on the PHP side of your site so you can easily manipulate data.

例如,如果您有一个User表,则获得此用户名就像执行以下操作一样容易:$myUser->getName();

For example if you have a User table, getting this user's name is as easy as doing: $myUser->getName();

在数据库中添加新用户将是:

adding a new user in your database would be:

$myUser = new User();
$myUser->setName('John Doe');
$myUser->save();

这当然是伪代码(实际上是PHP Symfony/Doctrine代码),但这是一个简单的示例,所以您明白了.

Of course this is pseudo code (actually PHP Symfony/Doctrine code), but it's a simple example so you get the point.

这篇关于Web应用程序中的ORM是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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