MiksIr
miksir@home:~$
AR - когда сущность инкапсулирует в себе доступ к базе. Т.е. когда сама сущность знает как себя сохранить и получить из базы. На то он и _Активный_
$user->getCountry() говорит ни о чем. Я не понимаю, почему это вдруг становится AR на основе взгляда на интерфейс. Если у нас реализация такая, что $user сам лезет в базу и достает Country - это похоже на AR. Но если у нас User получает Country другим способом, вплоть до обращения к какому-то сервису еще, это уже не AR.
Loading a typical order with multiple order lines may involve loading the order lines as well. The request from the client will usually lead to a graph of objects being loaded, with the mapper designer deciding exactly how much to pull back in one go. The point of this is to minimize database queries, so the finders typically need to know a fair bit about how clients use the objects in order to make the best choices for pulling data back.
Since objects are very interconnected, you usually have to stop pulling the data back at some point. Otherwise, you’re likely to pull back the entire database with a request. Again, mapping layers have techniques to deal with this while minimizing the impact on the in-memory objects, using Lazy Load (200).
...
On occasion you may need the domain objects to invoke find methods on the Data Mapper. However, I’ve found that with a good Lazy Load (200) you can completely avoid this. For simpler applications, though, may not be worth trying to manage everything with associations and Lazy Load (200). Still, you don’t want to add a dependency from your domain objects to your Data Mapper.
You can solve this dilemma by using Separated Interface (476). Put any find methods needed by the domain code into an interface class that you can place in the domain package.
Т.е. наличие у нас в User конструкции $this->_countryFinder->find($this->_countryId) ну совсем не делает AR.
$user->getCountry() говорит ни о чем. Я не понимаю, почему это вдруг становится AR на основе взгляда на интерфейс. Если у нас реализация такая, что $user сам лезет в базу и достает Country - это похоже на AR. Но если у нас User получает Country другим способом, вплоть до обращения к какому-то сервису еще, это уже не AR.
Loading a typical order with multiple order lines may involve loading the order lines as well. The request from the client will usually lead to a graph of objects being loaded, with the mapper designer deciding exactly how much to pull back in one go. The point of this is to minimize database queries, so the finders typically need to know a fair bit about how clients use the objects in order to make the best choices for pulling data back.
Since objects are very interconnected, you usually have to stop pulling the data back at some point. Otherwise, you’re likely to pull back the entire database with a request. Again, mapping layers have techniques to deal with this while minimizing the impact on the in-memory objects, using Lazy Load (200).
...
On occasion you may need the domain objects to invoke find methods on the Data Mapper. However, I’ve found that with a good Lazy Load (200) you can completely avoid this. For simpler applications, though, may not be worth trying to manage everything with associations and Lazy Load (200). Still, you don’t want to add a dependency from your domain objects to your Data Mapper.
You can solve this dilemma by using Separated Interface (476). Put any find methods needed by the domain code into an interface class that you can place in the domain package.
Т.е. наличие у нас в User конструкции $this->_countryFinder->find($this->_countryId) ну совсем не делает AR.