Is there something in PHP equivalent to LINQ in C#

2019-01-21 12:37发布

Is there something in PHP equivalent to LINQ in C#?

7条回答
家丑人穷心不美
2楼-- · 2019-01-21 12:58

See PHPLinq (a set of PHP classes mimicing C#3.0's LINQ).

查看更多
Deceive 欺骗
3楼-- · 2019-01-21 13:02

Try YaLinqo. It is the best LINQ for PHP.

Here is a comparison table:

Enter image description here

查看更多
叼着烟拽天下
4楼-- · 2019-01-21 13:06
一纸荒年 Trace。
5楼-- · 2019-01-21 13:06

A lot has changed in the PHP world over the last couple of years rendering most of the previous answers out of date.

Here is a new comparison table of the main LINQ implementations for PHP:

LINQ Library Comparison Table

These libraries can all be installed via composer.

In summary I would recommend the PINQ library (I am biased as I am the author) because it is actively maintained, well documented and tested and provides an implementation of true LINQ in PHP.

By true LINQ I mean that the library is not only a fluent collection API for in-memory arrays but also implements real query parsing with expression trees. This allows the integration of this API with external data sources hence PHP Integrated Query. A demo of such functionality can viewed here where queries are being compiled into SQL and run against a MySQL database:

查看更多
冷血范
6楼-- · 2019-01-21 13:06

There is also phinq which has a more recent release that PHPLinq, and it seems to look more like LINQ to Objects for C# than PHPLinq does.

查看更多
等我变得足够好
7楼-- · 2019-01-21 13:08

Good PHP ORM Library?

An answer to this question says

Look into Doctrine.

Doctrine 1.2 implements Active Record. Doctrine 2+ is a DataMapper ORM.

Also, check out Xyster. It's based on the Data Mapper pattern.

Also, take a look at DataMapper vs. Active Record.

查看更多
登录 后发表回答