且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Web应用程序中的ORM是什么?

更新时间:2023-01-14 09:20:14

它基本上使数据库表在站点的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.