What exactly is the difference between a data mapper and a repository?

Suppose your application manages Person objects, with each instance having name, age and jobTitle properties. You would like to persist such objects, retrieve them from the persistence medium and maybe update (say, on their birthday, increment the age) or delete. These tasks are usually referred to as CRUD, from Create, Read, Update and Delete. It … Read more

The advantages and disadvantages of using ORM [closed]

“ORM fail to compete against SQL queries for complex queries.” Well both LINQ-SQL and Entity Framework Allow complex queries and even translation of SQL query results into objects. “Developers loose understanding of what the code is actually doing – the developer is more in control using SQL.” Not really, if you know what you are … Read more

What are the advantages of using an ORM? [closed]

I’d say that if you aren’t dealing with objects there’s little point in using an ORM. If your relational tables/columns map 1:1 with objects/attributes, there’s not much point in using an ORM. If your objects don’t have any 1:1, 1:m or m:n relationships with other objects, there’s not much point in using an ORM. If … Read more

Doctrine 2 ArrayCollection filter method

Doctrine now has Criteria which offers a single API for filtering collections with SQL and in PHP, depending on the context. https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#filtering-collections Update This will achieve the result in the accepted answer, without getting everything from the database. use Doctrine\Common\Collections\Criteria; /** * @ORM\Entity */ class Member { // … public function getCommentsFiltered($ids) { $criteria = … Read more

Dapper.Rainbow VS Dapper.Contrib

I’ve been using Dapper for a while now and have wondered what the Contrib and Rainbow projects were all about myself. After a bit of code review, here are my thoughts on their uses: Dapper.Contrib Contrib provides a set of extension methods on the IDbConnection interface for basic CRUD operations: Get Insert Update Delete The … Read more