<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Data Mapper Pattern in PHP</title>
	<atom:link href="http://blog.tekerson.com/2008/12/17/data-mapper-pattern-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tekerson.com/2008/12/17/data-mapper-pattern-in-php/</link>
	<description>The inane, sometimes insane, ramblings from the mind of Brenton Alker.</description>
	<lastBuildDate>Fri, 06 Jan 2012 03:30:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: arash</title>
		<link>http://blog.tekerson.com/2008/12/17/data-mapper-pattern-in-php/comment-page-1/#comment-4371</link>
		<dc:creator>arash</dc:creator>
		<pubDate>Thu, 31 Dec 2009 10:31:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tekerson.com/?p=60#comment-4371</guid>
		<description>Hello, 

I&#039;ve started working with the DDD for a while and quite familiar with all the concepts but somehow putting them all together has been difficult for me. Until now I&#039;ve been using the repository to do the fetching from the database and using an internal mapper to map the fetched data into the entities. in your code where would the repository reside ?

thank you</description>
		<content:encoded><![CDATA[<p>Hello, </p>
<p>I&#8217;ve started working with the DDD for a while and quite familiar with all the concepts but somehow putting them all together has been difficult for me. Until now I&#8217;ve been using the repository to do the fetching from the database and using an internal mapper to map the fetched data into the entities. in your code where would the repository reside ?</p>
<p>thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brenton Alker</title>
		<link>http://blog.tekerson.com/2008/12/17/data-mapper-pattern-in-php/comment-page-1/#comment-184</link>
		<dc:creator>Brenton Alker</dc:creator>
		<pubDate>Sat, 03 Jan 2009 03:14:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tekerson.com/?p=60#comment-184</guid>
		<description>@TJ
I agree, it is difficult to find information on this topic especially in PHP (hence wanting to get some of my ideas out for feedback), it is often useful to have a look at implementations in other languages though.

In the UserMapper-&gt;findById() the $dataFromDb array could be gathered in any way you like. In the example it is hard coded (not very useful in reality, but used as a demonstration).
In practice, it could be done any way you like. e.g. via PDO with a manually written simple SQL query, complex SQL query or multiple SQL queries, fetched from a cache or a call to another layer of database abstraction. The only thing that matters from the Mappers point of view is that you end up with an array compatible with the populate() function.

The only job of the mapper is to decouple the domain objects (User) from the data store. So you can use (and test) the domain objects without caring about how the persistent storage is handled. In fact, as with all &quot;mappers&quot;, neither end of the &quot;mapping&quot; (DB, PHP Object) need (or should) be aware the mapper exists. This way, you could rewrite your entire data storage back end without touching your domain logic.</description>
		<content:encoded><![CDATA[<p>@TJ<br />
I agree, it is difficult to find information on this topic especially in PHP (hence wanting to get some of my ideas out for feedback), it is often useful to have a look at implementations in other languages though.</p>
<p>In the UserMapper->findById() the $dataFromDb array could be gathered in any way you like. In the example it is hard coded (not very useful in reality, but used as a demonstration).<br />
In practice, it could be done any way you like. e.g. via PDO with a manually written simple SQL query, complex SQL query or multiple SQL queries, fetched from a cache or a call to another layer of database abstraction. The only thing that matters from the Mappers point of view is that you end up with an array compatible with the populate() function.</p>
<p>The only job of the mapper is to decouple the domain objects (User) from the data store. So you can use (and test) the domain objects without caring about how the persistent storage is handled. In fact, as with all &#8220;mappers&#8221;, neither end of the &#8220;mapping&#8221; (DB, PHP Object) need (or should) be aware the mapper exists. This way, you could rewrite your entire data storage back end without touching your domain logic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TJ</title>
		<link>http://blog.tekerson.com/2008/12/17/data-mapper-pattern-in-php/comment-page-1/#comment-181</link>
		<dc:creator>TJ</dc:creator>
		<pubDate>Thu, 25 Dec 2008 11:38:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tekerson.com/?p=60#comment-181</guid>
		<description>Great post which I found quite usefull, however the key to data mappers is how do you map db relationships? Especially many-to-many relationships are a pain in the royal ass. Any thoughts about the DB relations subject would be appreciated! 

Although Google is my friend I find it hard to get anything usefull on this subject, e.g. how would you save a many-to-many relationship?

Thanks, TJ.</description>
		<content:encoded><![CDATA[<p>Great post which I found quite usefull, however the key to data mappers is how do you map db relationships? Especially many-to-many relationships are a pain in the royal ass. Any thoughts about the DB relations subject would be appreciated! </p>
<p>Although Google is my friend I find it hard to get anything usefull on this subject, e.g. how would you save a many-to-many relationship?</p>
<p>Thanks, TJ.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

