<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TYPO3Development &#187; My Projects</title>
	<atom:link href="http://blog.typoplanet.de/category/my-projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.typoplanet.de</link>
	<description>A blog for professional TYPO3 developers</description>
	<lastBuildDate>Mon, 28 Mar 2011 18:10:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Query the Linked Data Cloud using TYPO3</title>
		<link>http://blog.typoplanet.de/2011/03/28/query-linked-data-cloud-typo3/</link>
		<comments>http://blog.typoplanet.de/2011/03/28/query-linked-data-cloud-typo3/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 18:10:02 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Semantic Web integration]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[sparql]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=397</guid>
		<description><![CDATA[The Semantic Web is coming to a TYPO3 installation near you. During the TYPO3 Transition Days 2011 in Berlin a couple of Developers&#8212;including me&#8212;discussed about how to implement some aspects of the Semantic Web Stack for TYPO3. One of the first outcome is the new Extension &#8220;semantic&#8221; providing a SPARQL Client. You can query the [...]]]></description>
			<content:encoded><![CDATA[<p>The Semantic Web is coming to a <a href="http://typo3.org">TYPO3</a> installation near you. During the TYPO3 Transition Days 2011 in Berlin a couple of Developers&mdash;including me&mdash;discussed about how to implement some aspects of the Semantic Web Stack for TYPO3. One of the first outcome is the new <a href="http://forge.typo3.org/projects/show/extension-semantic">Extension &#8220;semantic&#8221;</a> providing a SPARQL Client.<br />
<span id="more-397"></span></p>
<p>You can query the <a href="http://linkeddata.org">Linked Data Cloud</a>&mdash;which includes the content of Wikipedia&mdash;by specifying a Query in the <a href="http://en.wikipedia.org/wiki/SPARQL">SPARQL Protocol and RDF Query Language</a>. For example, the statement to query for <em>People born in Boston before 1900</em> looks like:</p>
<div class="codecolorer-container mysql dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="mysql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">PREFIX foaf: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>xmlns.com<span style="color: #CC0099;">/</span>foaf<span style="color: #CC0099;">/</span><span style="color: #008080;">0.1</span><span style="color: #CC0099;">/&gt;</span><br />
PREFIX dbr: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>dbpedia.org<span style="color: #CC0099;">/</span>resource<span style="color: #CC0099;">/&gt;</span><br />
PREFIX dbo: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>dbpedia.org<span style="color: #CC0099;">/</span>ontology<span style="color: #CC0099;">/&gt;</span><br />
PREFIX xsd: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>www.w3.org<span style="color: #CC0099;">/</span><span style="color: #008080;">2001</span><span style="color: #CC0099;">/</span>XMLSchema<span style="color: #808080; font-style: italic;">#&gt;</span><br />
<br />
<span style="color: #990099; font-weight: bold;">SELECT</span> ?resource ?name ?birthDate ?deathDate<br />
<span style="color: #990099; font-weight: bold;">WHERE</span> <span style="color: #FF00FF;">&#123;</span><br />
&nbsp; ?resource a foaf:Person .<br />
&nbsp; ?resource foaf:name ?name .<br />
&nbsp; ?resource dbo:birthPlace dbr:Boston .<br />
&nbsp; ?resource dbo:birthDate ?birthDate .<br />
&nbsp; ?resource dbo:deathDate ?deathDate .<br />
&nbsp; FILTER <span style="color: #FF00FF;">&#40;</span>?birthDate <span style="color: #CC0099;">&lt;</span> <span style="color: #008000;">&quot;1900-01-01&quot;</span><span style="color: #CC0099;">^^</span>xsd:<span style="color: #999900; font-weight: bold;">date</span><span style="color: #FF00FF;">&#41;</span><br />
<span style="color: #FF00FF;">&#125;</span><br />
<span style="color: #990099; font-weight: bold;">ORDER BY</span> ?deathDate</div></td></tr></tbody></table></div>
<p>In the following video I will guide you through the installation of the Extension &#8220;semantic&#8221; and demo some of its features.</p>
<p><object width="604" height="364">
	<param name="movie" value="http://www.youtube.com/v/Kz_8RozC5eM?fs=1&amp;hl=en_US"></param>
	<param name="allowFullScreen" value="true"></param>
	<param name="allowscriptaccess" value="always"></param>
	<embed src="http://www.youtube.com/v/Kz_8RozC5eM?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="604" height="364"></embed>
</object></p>
<p>I have also recorded the first fifteen minutes in the life of the extension. In the following video you see how I kickstarted the extension. Keep in mind that the library ARC2 I used in this first step isn&#8217;t part of the extension anymore. All the code is now written from scratch, including the SPARQL Query Parser (see other posting).</p>
<p><object width="604" height="364">
	<param name="movie" value="http://www.youtube.com/v/w12fudccROs?fs=1&amp;hl=en_US"></param>
	<param name="allowFullScreen" value="true"></param>
	<param name="allowscriptaccess" value="always"></param>
	<embed src="http://www.youtube.com/v/w12fudccROs?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="604" height="364"></embed>
</object></p>
<p>If you have any specific questions about the extension or found an issue, please visit the projects page on Forge so we can keep track of it. You might also want to have a look at our roadmap or visit the Homepage of the <a href="http://www.typo3.org">TYPO3 community.</http:></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2011/03/28/query-linked-data-cloud-typo3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A SPARQL Query Result Parser written in PHP</title>
		<link>http://blog.typoplanet.de/2011/01/31/a-sparql-query-result-parser-written-in-php/</link>
		<comments>http://blog.typoplanet.de/2011/01/31/a-sparql-query-result-parser-written-in-php/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 17:21:14 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Meta Topics]]></category>
		<category><![CDATA[Semantic Web integration]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[sparql]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=411</guid>
		<description><![CDATA[Inspired by the SPARQL Query Result Parser written by Daniel Alexander Smith and published on the Enakting Blog, I just wrote an implementation in PHP. It utilizes the performant event based XML parser of PHP. In contrast to the original implementation written in Python, the current version below supports also the &#8220;datatype&#8221; and &#8220;xml:lang&#8221; attribute [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by the SPARQL Query Result Parser written by Daniel Alexander Smith and published on the <a href="http://blogs.ecs.soton.ac.uk/enakting/2011/01/28/fast-sparql-xml-results-parser-in-python/">Enakting Blog</a>, I just wrote an implementation in PHP. It utilizes the performant event based XML parser of PHP. In contrast to the original implementation written in Python, the current version below supports also the &#8220;datatype&#8221; and &#8220;xml:lang&#8221; attribute of literal types.<span id="more-411"></span></p>
<p>I have stripped off most of the comments and the copyright notice for better readability. You will find the <a href="http://forge.typo3.org/projects/extension-semantic/repository/entry/trunk/Classes/Domain/Model/Sparql/QueryResultParser.php">full code</a> on the project page. It also comes with <a href="http://forge.typo3.org/projects/extension-semantic/repository/entry/trunk/Tests/Unit/Domain/Model/Sparql/QueryResultParserTest.php">unit tests</a>.</p>
<p>This is just a small part of our attempt to integrate some techologies of the <a href="http://en.wikipedia.org/wiki/Semantic_Web_Stack">Semantic Web Stack</a> into TYPO3. For the current status of the project and our future plans, please see our <a href="http://forge.typo3.org/rb/master_backlogs/extension-semantic">product backlog</a>.</p>
<p>The script is part of the <a href="http://forge.typo3.org/projects/extension-semantic">Semantic Web Integration</a> project of TYPO3. You might also want to have a look at our roadmap or visit the Homepage of the <a href="http://www.typo3.org">TYPO3 community</a>.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Tx_Semantic_Domain_Model_Sparql_QueryResultParser implements Tx_Semantic_Domain_Model_Sparql_QueryResultParserInterface <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$parser</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentResult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentDataType</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentLanguage</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xml_parser_create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_set_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_set_element_handler</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'handleElementStart'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'handleElementStop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_set_character_data_handler</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'handleCharacterData'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_parser_free</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$document</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xml_parse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$document</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_Semantic_Domain_Model_Sparql_Exception_QueryResultParserException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Parser Error: &quot;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">xml_error_string</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">xml_get_error_code</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;.'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1296481762</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> handleElementStart<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$elementName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'VARIABLE'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'variables'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BINDING'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'LITERAL'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'literal'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DATATYPE'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DATATYPE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'XML:LANG'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'XML:LANG'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BNODE'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'bnode'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'URI'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'uri'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> handleElementStop<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$elementName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BINDING'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentCharacterData</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'datatype'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'LITERAL'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BNODE'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'URI'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'RESULT'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'results'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> handleCharacterData<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$characterData</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentCharacterData</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$characterData</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2011/01/31/a-sparql-query-result-parser-written-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A book about Extbase and Fluid</title>
		<link>http://blog.typoplanet.de/2010/07/06/book-about-extbase-and-fluid/</link>
		<comments>http://blog.typoplanet.de/2010/07/06/book-about-extbase-and-fluid/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 16:22:38 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[Development Process]]></category>
		<category><![CDATA[Extbase]]></category>
		<category><![CDATA[My Projects]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=382</guid>
		<description><![CDATA[Writing a book is a huge project. I never believed those people saying &#8220;Just double the time of your first estimate&#8221;. Now, after the book is finally available I would say they are wrong. You have to increase it threefold. The book about Extbase and Fluid was written in close collaboration with Sebastian Kurfürst (core [...]]]></description>
			<content:encoded><![CDATA[<p>Writing a book is a huge project. I never believed those people saying &#8220;Just double the time of your first estimate&#8221;. Now, after the book is finally available I would say they are wrong. You have to increase it threefold.</p>
<p>The book about <a href="http://forge.typo3.org/projects/typo3v4-mvc">Extbase</a> and <a href="http://forge.typo3.org/projects/show/package-fluid">Fluid</a> was written in close collaboration with Sebastian Kurfürst (core developer of Fluid) and Inken Kiupel (reader). We hope that it encourages the developers of TYPO3 extensions to get in touch with the fascinating concepts of FLOW3. And we hope that the book eases the migration to TYPO3 v5 (that&#8217;s what Extbase is all about).</p>
<p>We are aware of the fact that many of the English speaking TYPO3 developers are eagerly waiting for more Books about Extbase and Fluid  published in English. Sebastian Kurfürst and I are currently investigating the best way to to get the book translated into English to be published on <a href="http://www.typo3.org">typo3.org</a>.</p>
<p>If you have any questions regarding the book, or found some typos (at least 3), feel free to use the comments facility (if it is positive ;-) ) or write me an <a href="mailto:book@typoplanet.de">e-mail</a>. I am really looking forward to hear from you.</p>
<p>You might want to support our work by <a href="http://www.amazon.de/gp/product/3897219654?ie=UTF8&amp;tag=typoplanet-21&amp;linkCode=as2&amp;camp=1638&amp;creative=6742&amp;creativeASIN=3897219654">ordering the book through this link</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.de/e/ir?t=typoplanet-21&amp;l=as2&amp;o=3&amp;a=3897219654" border="0" alt="" width="1" height="1" />.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2010/07/06/book-about-extbase-and-fluid/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to Effectively use the Repository and Query Object of Extbase?</title>
		<link>http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/</link>
		<comments>http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 17:13:32 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Extbase]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[persistence]]></category>
		<category><![CDATA[query object]]></category>
		<category><![CDATA[repository]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=327</guid>
		<description><![CDATA[Extbase supports very well the idea of Domain-Driven Design. It supplies a Repository class to comfortably fetch your objects from. Some handy methods are already implemented. Let&#8217;s have a look at some example code. 12345678910111213141516171819202122$blog = new Tx_BlogExample_Domain_Model_Blog&#40;'TYPO3 Development'&#41;; $blog-&#62;setDescription&#40;'A blog for professional TYPO3 developers.'&#41;; $administrator = new Tx_BlogExample_Domain_Model_Administrator&#40;&#41;; $administrator-&#62;setName&#40;'Jochen Rau'&#41;; $administrator-&#62;setEmail&#40;'jochen.rau@example.com'&#41;; $blog-&#62;setAdministrator&#40;$administrator&#41;; $post = [...]]]></description>
			<content:encoded><![CDATA[<p>Extbase supports very well the idea of Domain-Driven Design. It supplies a <code class="codecolorer php dawn"><span class="php">Repository</span></code> class to comfortably fetch your objects from. Some handy methods are already implemented. <span id="more-327"></span> Let&#8217;s have a look at some example code.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$blog</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Blog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TYPO3 Development'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$blog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDescription</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'A blog for professional TYPO3 developers.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$administrator</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Administrator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$administrator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Jochen Rau'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$administrator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jochen.rau@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$blog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAdministrator</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$administrator</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Post<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Effectively use the Query Object of Extbase'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setContent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Extbase is a framework to develop ... hey, we\'re getting recursive now!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$comment</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Comment<span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDate</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAuthor</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Peter Pan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'peter.pan@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setContent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Do you need some pills?.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addComment</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$blog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addPost</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$blogRepository</span> <span style="color: #339933;">=</span> t3lib_div<span style="color: #339933;">::</span><span style="color: #004000;">makeInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tx_BlogExample_Domain_Repository_BlogRepository'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>In a first step, we create a new blog with an administrator, and a post with a comment. We instanciate the <code class="codecolorer php dawn"><span class="php">BlogRepository</span></code> in line 21 and add the blog to it. That&#8217;s all we have to do. The blog is now persisted and can be fetched later from the repository again. We don&#8217;t have to say <code class="codecolorer php dawn"><span class="php">save<span style="color: #009900;">&#40;</span><span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span></span></code> at any time. The repository &#8220;takes care&#8221; of the blog.</p>
<p>Keep in mind that you have to instanciate the repository with <code class="codecolorer php dawn"><span class="php">t3lib_div<span style="color: #339933;">::</span><span style="color: #004000;">makeInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> as it is a Singleton. If you instanciate it with <code class="codecolorer php dawn"><span class="php"><span style="color: #000000; font-weight: bold;">new</span></span></code> the Repository will be always an empty one if Extbase searches for objects to be persisted.</p>
<p>The <code class="codecolorer php dawn"><span class="php">BlogRepository</span></code> class is as simple as this:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Tx_BlogExample_Domain_Repository_BlogRepository <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">extends</span> Tx_Extbase_Persistence_Repository <span style="color: #009900;">&#123;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Most of the methods needed are already implemented in the <code class="codecolorer php dawn"><span class="php">Tx_Extbase_Persistence_Repository</span></code>. These are:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$existingObject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newObject</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$modifiedObject</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">countAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">countByProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findOneByProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span></div></div>
<p>The methods <code class="codecolorer php dawn"><span class="php">add<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> and <code class="codecolorer php dawn"><span class="php">remove<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> are self-explanatory. <code class="codecolorer php dawn"><span class="php">replace<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> takes an untracked object and puts it at the &#8220;place&#8221; of an existing one where <code class="codecolorer php dawn"><span class="php">update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> just takes an existing object and updates it with the property values of the modified object.</p>
<p>The <code class="codecolorer php dawn"><span class="php">findByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> and <code class="codecolorer php dawn"><span class="php">findOneByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> methods are magic methods where you can replace &#8220;Property&#8221; with the name of a property of the <code class="codecolorer php dawn"><span class="php">Blog</span></code> object. For example we can write <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Blog'</span><span style="color: #009900;">&#41;</span></span></code> to fetch all Blogs with the given title. This also works for objects like in <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByAdministrator</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$administrator</span><span style="color: #009900;">&#41;</span></span></code> but not yet for properties holding aggregates. Thus, <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByPost</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span></span></code> won&#8217;t work by now. <code class="codecolorer php dawn"><span class="php">findOneByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> is pretty similar to <code class="codecolorer php dawn"><span class="php">findByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> but returns the only first Object found.</p>
<p>The <code class="codecolorer php dawn"><span class="php">countAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> and <code class="codecolorer php dawn"><span class="php">countByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> methods are similar to the according <code class="codecolorer php dawn"><span class="php">find</span></code> methods. But the don&#8217;t build objects. They only count resulting objects.</p>
<p>All these methods keep the underlying storage solution (mostly a relational database) transparent to the user. But what if we have special constraints that are not covered with the methods above? Let&#8217;s say we want to find the five most recent posts of a given blog. Then we can use a <code class="codecolorer php dawn"><span class="php">Query</span></code> object.  Let&#8217;s ask the <code class="codecolorer php dawn"><span class="php">PostRepository</span></code> for those posts:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Tx_BlogExample_Domain_Repository_PostRepository<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">extends</span> Tx_Extbase_Persistence_Repository <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> findRecentByBlog<span style="color: #009900;">&#40;</span>Tx_BlogExample_Domain_Model_Blog <span style="color: #000088;">$blog</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matching</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrderings</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date'</span> <span style="color: #339933;">=&gt;</span> Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_DESCENDING</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLimit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integer<span style="color: #009900;">&#41;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The method <code class="codecolorer php dawn"><span class="php">createQuery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> returns an appropriate <code class="codecolorer php dawn"><span class="php">Query</span></code> object suitable for <code class="codecolorer php dawn"><span class="php">Post</span></code> objects. In Line 6 we define the constraint the posts should match: <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matching</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>constraint<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></span></code>. The constraint is returned by <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span></span></code>. There are some more methods returning a constraint:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logicalAnd</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$constraint1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$constraint2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logicalOr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$constraint1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$constraint2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logicalNot</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$constraint</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">withUid</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #339933;">,</span> <span style="color: #000088;">$caseSensitive</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">in</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">contains</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">like</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lessThan</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lessThanOrEqual</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">greaterThan</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">greaterThanOrEqual</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>We can define the orderings with <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrderings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>orderings<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></span></code> where <code class="codecolorer php dawn"><span class="php"><span style="color: #009900;">&#91;</span>orderings<span style="color: #009900;">&#93;</span></span></code> is expected to be an array of property-order pairs. There are two constants defining the order:</p>
<ul>
<li>Order ascending: <code class="codecolorer php dawn"><span class="php">Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_ASCENDING</span></span></code></li>
<li>Order descending: <code class="codecolorer php dawn"><span class="php">Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_DESCENDING</span></span></code></li>
</ul>
<p>We limit the result set to a maximum of five posts with <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLimit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integer<span style="color: #009900;">&#41;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span></span></code>. And finally invoke <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> which returns us the already build posts with all their comments inside (if we are not &#8220;lazy&#8221; ;-) ). There is also a method <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> which does  not fetch the resulting posts but counts them. Note that the <code class="codecolorer php dawn"><span class="php">Query</span></code> object enables chaining. Thus, the following code does the same as the given above:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> findRecentByBlog<span style="color: #009900;">&#40;</span>Tx_BlogExample_Domain_Model_Blog <span style="color: #000088;">$blog</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matching</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrderings</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date'</span> <span style="color: #339933;">=&gt;</span> Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_DESCENDING</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLimit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integer<span style="color: #009900;">&#41;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>That&#8217;s it for today. I hope you got a deeper insight and I am looking forward to your comments. Maybe you want to join the discussion on the related <a href="http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc">mailing list</a>. I have taken most of the code from the extension <code class="codecolorer php dawn"><span class="php">BlogExample</span></code> which is available in the <a href="http://typo3.org/extensions/repository/view/blog_example/current/">Extension Repository (TER)</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>A walk through the persistence layer of Extbase</title>
		<link>http://blog.typoplanet.de/2009/07/16/a-walk-trough-the-persistence-layer-of-extbase/</link>
		<comments>http://blog.typoplanet.de/2009/07/16/a-walk-trough-the-persistence-layer-of-extbase/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 09:34:16 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Extbase]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[flow3]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=275</guid>
		<description><![CDATA[Extbase is the new frame-work for TYPO3 extension developers introduced in TYPO3 v4.3. In this article I will give you a brief overview over the persistence layer of Extbase. It falls into different (sub)layers — each of the with different responsibilities. Let&#8217;s start our journey from the top level. 1. Repository A Repository is the first [...]]]></description>
			<content:encoded><![CDATA[<p>Extbase is the new frame-work for <a title="TYPO3 project page" href="http://www.typo3.org">TYPO3</a> extension developers introduced in TYPO3 v4.3. In this article I will give you a brief overview over the persistence layer of Extbase. It falls into different (sub)layers — each of the with different responsibilities. Let&#8217;s start our journey from the top level.<span id="more-275"></span></p>
<p><strong>1. Repository</strong></p>
<p>A Repository is the first objects a developer comes in contact to. It handles only domain objects and provide task oriented interface to retrieve them by saying findByFoo(&#8216;Bar&#8217;). Most of the time you are done.</p>
<p><strong>2. Query</strong></p>
<p>The next level is the Query object. It provides methods to create an abstract query (abstract in sense of abstracted from where the objects come from). It has no clue about the underlying structure of the storage. It even does not now if it is based on a relational model or a tree model (like the content repository of [FLOW3|FLOW3 is a next generation web application framework built for the upcoming TYPO3 v5]). It also invokes the DataMapper (see below). An extension developer uses the Query object to create his own findByFoo() methods for  his Repositories.</p>
<p><strong>3. QueryObjectModel</strong></p>
<p>Deeper and deeper we dig &#8230; In comparison to the Query object Query Object Model knows about the underlying concepts of relations and thus Joins and Orderings. An extension developer may use this class to specify more complex and &#8220;relational model&#8221; aware queries. That makes the creation of queries (esp. Joins) al little bit laborious. But it helps to keep abstraction.</p>
<p><strong>4. StorageBackend</strong></p>
<p>The Storage Backend translates the Query Object Model in syntactical correct statement (SQL). It also invokes the call to the database via a handler. An extension developer normally does not have to mak his hands dirty with SQL (which is in most cases the best way to improve performance and security).</p>
<p><strong>5. DatabaseHandler</strong></p>
<p>The Database Handler prepares queries, fetches the result set. It can be simply the [t3lib_db|A class in TYPO3 providing methods to access a database], or [PDO|PHP Data Objects], or your preferred solution.</p>
<p><strong>6. DataMapper</strong></p>
<p>And finally the Data Mapper. It maps the resulting rows on the Domain Object (it creates an empty object and fills it with the converted property values). It also resolves relations according to the loading strategy (eg. Lazy Loading Proxy).</p>
<p>Puh! Now we are done. Hope you enjoyed the journey.</p>
<p><strong>F.A.Q</strong></p>
<p><strong>Q</strong> Are you nuts! Six different layers, dozens of objects, and bunch of new things to learn! I only wanted to say &#8220;SELECT * FROM Tx_MyExt_Foo WHERE &#8230;&#8221;!<br />
<strong>A</strong> You are right: I am nuts (at least a litte bit ;-)). But now we are fully compatible to the (Query) API of FLOW3 and reached the best level to port Extensions forward. And I really like the Idea of having totally freedom of choice.</p>
<p><strong>Q</strong> And what about performance?<br />
<strong>A</strong> That’s indeed a very important point. We will do some extensive profiling sessions, implement Lazy Loading strategies, and strive for optimized Queries.</p>
<p>And please keep in mind: 90% of the work is based on the concepts and code of <a title="FLOW3 project page" href="http://flow3.typo3.org/">FLOW3</a>. Credits goes to the FLOW3 team.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2009/07/16/a-walk-trough-the-persistence-layer-of-extbase/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

