<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">

<channel>
	<title>./sklueh</title>
	<atom:link href="https://www.sklueh.de/feed/" rel="self" type="application/rss+xml"/>
	<link>https://www.sklueh.de</link>
	<description>devblog</description>
	<lastBuildDate>Mon, 07 Aug 2023 20:45:58 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.4</generator>

<image>
	<url>https://www.sklueh.de/wp-content/uploads/2023/02/cropped-512x512-00000000-32x32.png</url>
	<title>./sklueh</title>
	<link>https://www.sklueh.de</link>
	<width>32</width>
	<height>32</height>
</image> 
	<itunes:explicit>no</itunes:explicit><itunes:keywords>php,jquery,c,postgresql,mysql,javascript,html,css,regex</itunes:keywords><itunes:subtitle>Softwareentwicklung und was mich sonst so beschäftigt.</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Software How-To"/></itunes:category><itunes:author>Sebastian Klüh</itunes:author><item>
		<title>Vom Start zum Ziel: Pfadsuch-Algorithmus</title>
		<link>https://www.sklueh.de/2023/08/vom-start-zum-ziel-pfadsuch-algorithmus/</link>
		
		
		<pubDate>Mon, 07 Aug 2023 20:38:05 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<guid isPermaLink="false">https://www.sklueh.de/?p=2146</guid>

					<description><![CDATA[Stellen Sie sich vor, Sie befinden sich in einem riesigen Labyrinth und suchen den Ausgang. Jede falsche Abzweigung kostet wertvolle Zeit. Zum Glück gibt es in der Informatik Algorithmen, die genau dieses Problem lösen: Pfadsuch-Algorithmen. In diesem Artikel tauchen wir in einen solchen Algorithmus ein und erkunden, wie er funktioniert. Das Labyrinth Unser Labyrinth ist &#8230; <a href="https://www.sklueh.de/2023/08/vom-start-zum-ziel-pfadsuch-algorithmus/" class="more-link"><span class="screen-reader-text">Vom Start zum Ziel: Pfadsuch-Algorithmus</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.sklueh.de/wp-content/uploads/2023/08/pathfinder.png"><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-2160" src="https://www.sklueh.de/wp-content/uploads/2023/08/pathfinder-300x294.png" alt="" width="300" height="294" srcset="https://www.sklueh.de/wp-content/uploads/2023/08/pathfinder-300x294.png 300w, https://www.sklueh.de/wp-content/uploads/2023/08/pathfinder-768x753.png 768w, https://www.sklueh.de/wp-content/uploads/2023/08/pathfinder.png 929w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Stellen Sie sich vor, Sie befinden sich in einem riesigen Labyrinth und suchen den Ausgang. Jede falsche Abzweigung kostet wertvolle Zeit. Zum Glück gibt es in der Informatik Algorithmen, die genau dieses Problem lösen: Pfadsuch-Algorithmen. In diesem Artikel tauchen wir in einen solchen Algorithmus ein und erkunden, wie er funktioniert.<br />
<span id="more-2146"></span></p>
<h3>Das Labyrinth</h3>
<p>Unser Labyrinth ist ein einfaches Raster aus Zellen, die entweder Wände (1) oder offene Pfade (0) darstellen. Es wird auf einem Canvas gezeichnet, wobei jede Zelle eine Größe von 20 Pixeln hat. Das Labyrinth kann in zwei Modi generiert werden: Einem Standardmodus und einem Dichtemodus. Im Dichtemodus sind die Wände zufällig verteilt, was das Labyrinth unberechenbar macht.</p>
<h3>Der Pfadsuch-Algorithmus</h3>
<p>Der Kern unseres Programms ist der Pfadsuch-Algorithmus. Er verwendet eine Methode namens A*, die eine Kombination aus Distanz zum Ziel und zurückgelegtem Weg verwendet, um den besten Pfad zu finden. Das klingt kompliziert, aber im Grunde genommen versucht der Algorithmus, den kürzesten Weg zum Ziel zu finden, indem er die bereits zurückgelegte Distanz und die geschätzte verbleibende Distanz berücksichtigt.</p>
<h3>Herausforderungen</h3>
<p>Eine der größten Herausforderungen bei der Implementierung dieses Algorithmus war die Behandlung von Wänden und offenen Pfaden. Der Algorithmus muss sicherstellen, dass er nicht durch Wände geht und dass er immer den kürzesten Weg zum Ziel findet.</p>
<p>Ein weiteres Problem war die Interaktion mit dem Benutzer. Wir wollten, dass der Benutzer den Endpunkt des Pfads in Echtzeit verschieben kann, indem er mit der Maus über das Canvas fährt. Dies bedeutete, dass der Algorithmus sehr schnell arbeiten musste, um in Echtzeit zu reagieren.</p>
<h3>Der Code</h3>
<p>Der wichtigste Teil des Algorithmus ist die Bewertungsfunktion:</p>
<div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">// Funktion zum Schätzen der Distanz</span><br />
<br />
<span style="color: #000066; font-weight: bold;">function</span> heuristic<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000066; font-weight: bold;">return</span> <span style="">Math</span>.<span style="color: #660066;">abs</span><span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">x</span> <span style="color: #339933;">-</span> b.<span style="color: #660066;">x</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="">Math</span>.<span style="color: #660066;">abs</span><span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">y</span> <span style="color: #339933;">-</span> b.<span style="color: #660066;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">function</span> findPath<span style="color: #009900;">&#40;</span>start<span style="color: #339933;">,</span> end<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// ...</span><br />
<br />
let gScore <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Die Kosten, um von Start zu diesem Punkt zu gelangen</span><br />
let fScore <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Die geschätzten Kosten von diesem Punkt zum Ziel</span><br />
<br />
<span style="color: #006600; font-style: italic;">// ...</span></div></div>
<p>Die heuristic-Funktion gibt eine Schätzung der Distanz zwischen zwei Punkten zurück. gScore speichert die tatsächliche Distanz vom Startpunkt zu einem bestimmten Punkt, während fScore die Kombination aus gScore und der heuristischen Schätzung der Distanz zum Ziel ist.</p>
<h3>Fazit</h3>
<p>Pfadsuch-Algorithmen sind ein faszinierendes Thema in der Informatik. Sie haben zahlreiche Anwendungen, von Videospielen bis hin zu Robotik. Mit dem richtigen Verständnis und ein wenig Übung können Sie diese Algorithmen nutzen, um komplexe Probleme zu lösen und beeindruckende interaktive Anwendungen zu erstellen.</p>
<h3>Links</h3>
<p><a href="https://sklueh.de/sandbox/pathfinder/pathfinder.html">Beispiel</a><br />
<a href="https://github.com/sklueh/pathfinder">Github-Repo</a></p>
]]></content:encoded>
					
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>Unschärfeeffekt mit CSS</title>
		<link>https://www.sklueh.de/2017/12/unschaerfeeffekt-mit-css/</link>
					<comments>https://www.sklueh.de/2017/12/unschaerfeeffekt-mit-css/#respond</comments>
		
		
		<pubDate>Sun, 10 Dec 2017 12:41:19 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[blur]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[Effekt]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[unscharf]]></category>
		<category><![CDATA[unschärfe]]></category>
		<guid isPermaLink="false">https://sklueh.de/?p=2068</guid>

					<description><![CDATA[Unschärfeeffekte lassen sich in CSS über die Filter-Property realisieren. Sobald die Style-Klasse festgelegt wurde, kann man diese auf ein DIV oder beliebiges Element anwenden. Screenshot Code: .blurout &#123; &#160; &#160; &#160; &#160; &#160; &#160; /* Transparenz festlegen */ &#160; &#160; &#160; &#160; &#160; &#160; opacity: 0.85; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#8230; <a href="https://www.sklueh.de/2017/12/unschaerfeeffekt-mit-css/" class="more-link"><span class="screen-reader-text">Unschärfeeffekt mit CSS</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>Unschärfeeffekte lassen sich in CSS über die Filter-Property realisieren. Sobald die Style-Klasse festgelegt wurde, kann man diese auf ein DIV oder beliebiges Element anwenden.</p>
<p><a href="https://sklueh.de/wp-content/uploads/2017/12/blur-out-effect.png">Screenshot</a></p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container css railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.blurout</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Transparenz festlegen */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">opacity</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0.85</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Postition festlegen */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Unschärfe festlegen */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">filter</span><span style="color: #00AA00;">:</span> blur<span style="color: #00AA00;">&#40;</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -webkit-filter<span style="color: #00AA00;">:</span> blur<span style="color: #00AA00;">&#40;</span><span style="color: #933;">5px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -moz-filter<span style="color: #00AA00;">:</span> blur<span style="color: #00AA00;">&#40;</span><span style="color: #933;">5px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -o-filter<span style="color: #00AA00;">:</span> blur<span style="color: #00AA00;">&#40;</span><span style="color: #933;">5px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ms-filter<span style="color: #00AA00;">:</span> blur<span style="color: #00AA00;">&#40;</span><span style="color: #933;">5px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></div>
<p><span id="more-2068"></span></p>
<p><strong>Beispiel:</strong></p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; .blurout {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Transparenz festlegen */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacity: 0.85; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Postition festlegen */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position: absolute;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left: 0; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; right: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bottom: 0; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Unschärfe festlegen */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filter: blur(5px;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -webkit-filter: blur(5px);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -moz-filter: blur(5px);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -o-filter: blur(5px);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ms-filter: blur(5px);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blurout&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dolor sit amet. &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2017/12/unschaerfeeffekt-mit-css/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>Xamarin Dev Days in Frankfurt @ SDX</title>
		<link>https://www.sklueh.de/2017/09/xamarin-dev-days-in-frankfurt-sdx/</link>
					<comments>https://www.sklueh.de/2017/09/xamarin-dev-days-in-frankfurt-sdx/#respond</comments>
		
		
		<pubDate>Sun, 17 Sep 2017 12:04:23 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Xamarin]]></category>
		<guid isPermaLink="false">https://v22016073709035970.powersrv.de/workspace/sklueh/sklueh.de/wordpress/?p=2060</guid>

					<description><![CDATA[Am Freitag (15.09.2017) habe ich an den Xamarin DEV DAYS in Frankfurt@SDX_AG teilgenommen. Insgesamt eine inhaltlich wertvolle Veranstaltung. Neben einem groben Überblick über verschiedene Technologien (Xamarin, Xamarin Forms, Anbindung an Azure) hatte man die Möglichkeit sich mit Fragen an die Referenten zu wenden. Abgerundet wurde dieses Event mit dem obligatorischen Bier nach vier. Wer Interesse &#8230; <a href="https://www.sklueh.de/2017/09/xamarin-dev-days-in-frankfurt-sdx/" class="more-link"><span class="screen-reader-text">Xamarin Dev Days in Frankfurt @ SDX</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>Am Freitag (15.09.2017) habe ich an den Xamarin <a href="https://ti.to/xamarin/dev-days-frankfurt-2017/en" rel="noopener" target="_blank">DEV DAYS</a> in Frankfurt@SDX_AG teilgenommen. Insgesamt eine inhaltlich wertvolle Veranstaltung. Neben einem groben Überblick über verschiedene Technologien (Xamarin, Xamarin Forms, Anbindung an Azure) hatte man die Möglichkeit sich mit Fragen an die Referenten zu wenden. Abgerundet wurde dieses Event mit dem obligatorischen Bier nach vier.</p>
<p>Wer Interesse hat, kann sich die Beispielprojekte aus dem Hands-on auf Github ansehen:</p>
<p><a href="https://github.com/xamarin/dev-days-labs" rel="noopener" target="_blank">https://github.com/xamarin/dev-days-labs</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2017/09/xamarin-dev-days-in-frankfurt-sdx/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>MySQL-Datenbank mit PHP sichern</title>
		<link>https://www.sklueh.de/2016/04/mysql-datenbank-mit-php-sichern/</link>
					<comments>https://www.sklueh.de/2016/04/mysql-datenbank-mit-php-sichern/#respond</comments>
		
		
		<pubDate>Wed, 27 Apr 2016 19:34:54 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[backuppen]]></category>
		<category><![CDATA[datenbank]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sichern]]></category>
		<category><![CDATA[sql]]></category>
		<guid isPermaLink="false">https://sklueh.de/?p=2009</guid>

					<description><![CDATA[Mit dem folgenden Code können MySQL-Datenbanken auf einfache Weise gesichert werden. Es müssen lediglich die Verbindungs-Parameter an die Methode &#8222;backupMySQLDB&#8220; übergeben werden. Optional kann noch ein Dateinamen für die Backup-Datei angegeben werden. Code: function backupMySQLDB&#40;$sDBUser, $sDBPassword, $sDBName, $sDBHost = &#34;localhost&#34;, $sDBBackupFile = &#34;&#34;&#41; &#123; &#160; &#160; set_time_limit&#40;0&#41;; &#160; &#160; $sOutput = &#34;&#34;; &#160; &#160; $oConnection &#8230; <a href="https://www.sklueh.de/2016/04/mysql-datenbank-mit-php-sichern/" class="more-link"><span class="screen-reader-text">MySQL-Datenbank mit PHP sichern</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>Mit dem folgenden Code können MySQL-Datenbanken auf einfache Weise gesichert werden. Es müssen lediglich die Verbindungs-Parameter an die Methode &#8222;backupMySQLDB&#8220; übergeben werden. Optional kann noch ein Dateinamen für die Backup-Datei angegeben werden.</p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container php railscasts" 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: #000000; font-weight: bold;">function</span> backupMySQLDB<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sDBUser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sDBPassword</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sDBName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sDBHost</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sDBBackupFile</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #990000;">set_time_limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$sOutput</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$oConnection</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mysqli<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sDBHost</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sDBUser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sDBPassword</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sDBName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$mTables</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$oConnection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLES&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$aTable</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mTables</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sOutput</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;DROP TABLE IF EXISTS `&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$aTable</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Tables_in_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$sDBName</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;`;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$aResult</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$oConnection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW CREATE TABLE `&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$aTable</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Tables_in_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$sDBName</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;`&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_assoc</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;">$sOutput</span><span style="color: #339933;">.=</span><span style="color: #000088;">$aResult</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Create Table'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rResult</span> <span style="color: #339933;">=</span><span style="color: #000088;">$oConnection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM `&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$aTable</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Tables_in_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$sDBName</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;`&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aRow</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rResult</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sOutput</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;INSERT INTO `&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$aTable</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Tables_in_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$sDBName</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;` VALUES('&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;', '&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_values</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aRow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rOutput</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sDBBackupFile</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span> ? <span style="color: #0000ff;">&quot;Backup-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sDBName</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d_H-i'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.sql&quot;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$sDBBackupFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sOutput</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rOutput</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-2009"></span><br />
<strong>Beispiel:</strong></p>
<div class="codecolorer-container php railscasts" 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;">backupMySQLDB<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;my_password&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;my_database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Über Feedback und Verbesserungsvorschläge würde ich mich sehr freuen 🙂 .</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2016/04/mysql-datenbank-mit-php-sichern/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>PHP: Verzeichnis rekursiv kopieren</title>
		<link>https://www.sklueh.de/2016/04/php-verzeichnis-rekursiv-kopieren/</link>
					<comments>https://www.sklueh.de/2016/04/php-verzeichnis-rekursiv-kopieren/#respond</comments>
		
		
		<pubDate>Sun, 24 Apr 2016 07:22:17 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[kopieren]]></category>
		<category><![CDATA[recursively]]></category>
		<category><![CDATA[rekursiv]]></category>
		<category><![CDATA[verzeichnis]]></category>
		<guid isPermaLink="false">http://sklueh.de/?p=1997</guid>

					<description><![CDATA[PHP bietet leider keine Möglichkeit um ein Verzeichnis inkl. aller Unterordner an einen anderen Ort zu kopieren. Hierfür kann die folgende Methode verwendet werden: Code: function copyDir&#40;$sSourcePath, $sTargetPath&#41; &#123; &#160; &#160; &#160; if &#40;is_dir&#40;$sSourcePath&#41; &#38;&#38; !is_dir&#40;$sTargetPath&#41;&#41; &#160; &#160; &#123; &#160; &#160; &#160; &#160; mkdir&#40;$sTargetPath, 0755&#41;; &#160; &#160; &#160; &#160; foreach &#40;$oIterator = new \RecursiveIteratorIterator&#40; &#160; &#8230; <a href="https://www.sklueh.de/2016/04/php-verzeichnis-rekursiv-kopieren/" class="more-link"><span class="screen-reader-text">PHP: Verzeichnis rekursiv kopieren</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>PHP bietet leider keine Möglichkeit um ein Verzeichnis inkl. aller Unterordner an einen anderen Ort zu kopieren. Hierfür kann die folgende Methode verwendet werden:</p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container php railscasts" 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: #000000; font-weight: bold;">function</span> copyDir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sSourcePath</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sTargetPath</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sSourcePath</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sTargetPath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sTargetPath</span><span style="color: #339933;">,</span> <span style="color: #208080;">0755</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$oIterator</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \RecursiveIteratorIterator<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> \RecursiveDirectoryIterator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sSourcePath</span><span style="color: #339933;">,</span> \RecursiveDirectoryIterator<span style="color: #339933;">::</span><span style="color: #004000;">SKIP_DOTS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \RecursiveIteratorIterator<span style="color: #339933;">::</span><span style="color: #004000;">SELF_FIRST</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$oItem</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$oItem</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isDir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sTargetPath</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">.</span><span style="color: #000088;">$oIterator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSubPathName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$oItem</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sTargetPath</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">.</span><span style="color: #000088;">$oIterator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSubPathName</span><span style="color: #009900;">&#40;</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: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-1997"></span><br />
<strong>Beispiel:</strong></p>
<div class="codecolorer-container php railscasts" 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;">copyDir<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;./source&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;./target&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Für Feedback und Verbesserungsmöglichkeiten kann die Kommentarfunktion benutzt werden 🙂 .</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2016/04/php-verzeichnis-rekursiv-kopieren/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>PHPCache</title>
		<link>https://www.sklueh.de/2015/03/phpcache/</link>
					<comments>https://www.sklueh.de/2015/03/phpcache/#respond</comments>
		
		
		<pubDate>Sat, 21 Mar 2015 07:10:41 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[zwischenspeicher]]></category>
		<guid isPermaLink="false">http://sklueh.de/?p=1937</guid>

					<description><![CDATA[PHPCache ist eine PHP-Klasse mit der sich beliebige Werte für eine festgelegte Zeit zwischenspeichern lassen. Die zu speichernden Werte werden serialisiert und in eine Cache-Datei geschrieben. Beim Abrufen des Wertes wird das Änderungsdatum der Cache-Datei gelesen. Befindet sich dieses innerhalb des festgelegten Zeitraums, so wird der gecachte Wert zurückgegeben. Beispiel: &#160;$oCache = new PHPCache&#40;&#41;; &#160;//to &#8230; <a href="https://www.sklueh.de/2015/03/phpcache/" class="more-link"><span class="screen-reader-text">PHPCache</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://github.com/sklueh/PHPCache/" title="PHPCache" target="_blank">PHPCache</a> ist eine PHP-Klasse mit der sich beliebige Werte für eine festgelegte Zeit zwischenspeichern lassen. Die zu speichernden Werte werden serialisiert und in eine Cache-Datei geschrieben. Beim Abrufen des Wertes wird das Änderungsdatum der Cache-Datei gelesen. Befindet sich dieses innerhalb des festgelegten Zeitraums, so wird der gecachte Wert zurückgegeben.</p>
<p><strong>Beispiel:</strong></p>
<div class="codecolorer-container php railscasts" 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;">&nbsp;<span style="color: #000088;">$oCache</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PHPCache<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp;<span style="color: #666666; font-style: italic;">//to clear cache manually.</span><br />
&nbsp;<span style="color: #666666; font-style: italic;">//$oCache-&gt;clear('my_cache');</span><br />
<br />
&nbsp;<span style="color: #666666; font-style: italic;">//to clear whole cache directory</span><br />
&nbsp;<span style="color: #666666; font-style: italic;">//$oCache-&gt;clear();</span><br />
<br />
&nbsp;<span style="color: #666666; font-style: italic;">//data will be cached for 30 seconds. Second parameter is optional.</span><br />
&nbsp;<span style="color: #000088;">$mData</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$oCache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'my_cache'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp;<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$mData</span><span style="color: #009900;">&#41;</span><br />
&nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000088;">$mData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Wert 1'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Blaaa'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">//save data to cache&quot;;</span><br />
&nbsp; &nbsp;<span style="color: #000088;">$oCache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'my_cache'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//get cached data</span><br />
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><span id="more-1937"></span></p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container php railscasts" 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: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> PHPCache<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$sDirectory</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;cache&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$sExtension</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;cache&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$iExpiration</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">900</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* 15 minutes */</span>&nbsp; <br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> PHPCache<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sDirectory</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$iExpiration</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sExtension</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sDirectory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sDirectory</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sDirectory</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sDirectory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sDirectory</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</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 />
&nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$iExpiration</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">iExpiration</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$iExpiration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sExtension</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sExtension</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sExtension</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> set<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mData</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$sCachePath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sDirectory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rCacheFile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wb'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rCacheFile</span><span style="color: #339933;">,</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mData</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rCacheFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">@</span><span style="color: #990000;">chmod</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #339933;">,</span> <span style="color: #000088;">$iExpiration</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$mCache</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$iExpiration</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">iExpiration</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$iExpiration</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rCacheFile</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$mCache</span> <span style="color: #339933;">=</span> <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rCacheFile</span><span style="color: #339933;">,</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rCacheFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$mCache</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> clear<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">glob</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sDirectory</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/*.'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sExtension</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$sFile</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sCachePath</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sDirectory</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">sha1</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sExtension</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><strong>Github:</strong> <a href="https://github.com/sklueh/PHPCache/" title="PHPCache" target="_blank">PHPCache</a></p>
<p>Für Ideen &amp; Verbesserungsvorschläge, einfach die Kommentarfunktion nutzen.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2015/03/phpcache/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>PHP: MySQL Query Funktion</title>
		<link>https://www.sklueh.de/2014/11/php-mysql-query-funktion/</link>
					<comments>https://www.sklueh.de/2014/11/php-mysql-query-funktion/#comments</comments>
		
		
		<pubDate>Sat, 15 Nov 2014 08:32:36 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[sql]]></category>
		<guid isPermaLink="false">http://sklueh.de/?p=1859</guid>

					<description><![CDATA[Über die Methode &#8222;query&#8220; lassen sich beliebige SQL-Queries ausführen. Der Parameter &#8222;sSQL&#8220; enthält das Query. Der Rückgabewert enthält entweder das Result Set als Array oder true / false im Erfolgs- bzw. Fehler-Fall. Bevor die Methode verwendet werden kann, müssen noch der Benutzername, das Passwort und ggf. der Hostname für die Datenbankverbindung festgelegt werden. Update 01.03.2015: &#8230; <a href="https://www.sklueh.de/2014/11/php-mysql-query-funktion/" class="more-link"><span class="screen-reader-text">PHP: MySQL Query Funktion</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>Über die Methode &#8222;query&#8220; lassen sich beliebige SQL-Queries ausführen. Der Parameter &#8222;sSQL&#8220; enthält das Query. Der Rückgabewert enthält entweder das Result Set als Array oder true / false im Erfolgs- bzw. Fehler-Fall. Bevor die Methode verwendet werden kann, müssen noch der Benutzername, das Passwort und ggf. der Hostname für die Datenbankverbindung festgelegt werden.</p>
<p><strong>Update 01.03.2015:</strong><br />
&#8211; &#8222;mysql_&#8220;-Funktionen wurden entfern, da deprecated<br />
&#8211; Verbindung wird nur noch einmal aufgebaut</p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container php railscasts" 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: #000000; font-weight: bold;">function</span> query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sSQL</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; static <span style="color: #000088;">$oConnection</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Change user / password / database!</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$oConnection</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$oConnection</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mysqli<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #000088;">$mResult</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$oConnection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sSQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mResult</span> instanceof mysqli_result<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$aResult</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; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$aRow</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mResult</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$aResult</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$aRow</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$mResult</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</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;">$mResult</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$aResult</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$mResult</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-1859"></span></p>
<p><strong>Beispiel:</strong></p>
<div class="codecolorer-container php railscasts" 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: #990000;">var_dump</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO clients (name) VALUES ('bla')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//true</span><br />
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE clients SET name = 'test' WHERE id = 51000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//true</span><br />
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM clients&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//array</span><br />
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;THIS IS NOT A QUERY&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//false</span></div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2014/11/php-mysql-query-funktion/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>Templates parsen in PHP</title>
		<link>https://www.sklueh.de/2014/10/templates-parsen-in-php/</link>
					<comments>https://www.sklueh.de/2014/10/templates-parsen-in-php/#respond</comments>
		
		
		<pubDate>Sun, 26 Oct 2014 07:00:06 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[template]]></category>
		<guid isPermaLink="false">http://sklueh.de/?p=1862</guid>

					<description><![CDATA[Die Funktion &#8222;parseTemplate&#8220; bietet eine schlanke Alternative zu einer komplexen Template-Engine. Der erste Parameter enthält die Template Datei. Der zweite Parameter enthält die Variablen, die geparst werden sollen. Code: function parseTemplate&#40;$sTemplateFile, $aVariables = array&#40;&#41;&#41; &#123; &#160; &#160; if&#40;file_exists&#40;$sTemplateFile&#41;&#41; &#160; &#160; &#123; &#160; &#160; &#160; &#160; extract&#40;$aVariables&#41;; &#160; &#160; &#160; &#160; include&#40;$sTemplateFile&#41;; &#160; &#160; &#125; &#125; &#8230; <a href="https://www.sklueh.de/2014/10/templates-parsen-in-php/" class="more-link"><span class="screen-reader-text">Templates parsen in PHP</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>Die Funktion &#8222;parseTemplate&#8220; bietet eine schlanke Alternative zu einer komplexen Template-Engine. Der erste Parameter enthält die Template Datei. Der zweite Parameter enthält die Variablen, die geparst werden sollen.</p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container php railscasts" 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: #000000; font-weight: bold;">function</span> parseTemplate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sTemplateFile</span><span style="color: #339933;">,</span> <span style="color: #000088;">$aVariables</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: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sTemplateFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aVariables</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sTemplateFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-1862"></span></p>
<p><strong>Template &#8211; beispiel.tmpl.php:</strong><br />
Die Templates schreibt man in gewohntem PHP. Durch die Verwendung von short tags lässt sich das Template weiter vereinfachen.</p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Hallo <span style="color: #009900;">&lt;?php echo $name; ?&gt;</span>,<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span><br />
meine Lieblingsfarben sind:<br />
<span style="color: #009900;">&lt;?php if<span style="color: #66cc66;">&#40;</span>!empty<span style="color: #66cc66;">&#40;</span>$colors<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>: ?&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ol</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;?php foreach<span style="color: #66cc66;">&#40;</span>$colors as $color<span style="color: #66cc66;">&#41;</span>: ?&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;?php echo $color; ?&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;?php endforeach; ?&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ol</span>&gt;</span><br />
<span style="color: #009900;">&lt;?php endif; ?&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span> ... Inhalt ... <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></div>
<p><strong>Beispiel:</strong></p>
<div class="codecolorer-container php railscasts" 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;">parseTemplate<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'beispiel.tmpl.php'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'colors'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Gelb'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Rot'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Blau'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">'name'</span> &nbsp; <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Besucher'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2014/10/templates-parsen-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>ShareMySnippets Plugin für Eclipse</title>
		<link>https://www.sklueh.de/2014/07/sharemysnippets-plugin-fuer-eclipse/</link>
					<comments>https://www.sklueh.de/2014/07/sharemysnippets-plugin-fuer-eclipse/#respond</comments>
		
		
		<pubDate>Tue, 15 Jul 2014 05:33:45 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[share-my-snippets.de]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[tools]]></category>
		<guid isPermaLink="false">http://sklueh.de/?p=1812</guid>

					<description><![CDATA[Das ShareMySnippets-Plugin ist eine Erweiterung für Eclipse mit der sich Code-Snippets von Share-My-Snippets.de direkt in die IDE einfügen lassen. Über ein Suchfeld können alle öffentlichen Snippets nach den entsprechenden Begriffen durchsucht werden. Snippets einfügen: Über den Menü-Punkt &#8222;Share My Snippets > Browse Snippets&#8220; können die Snippets eingefügt werden: Installation: Menü: Help > Install New Software &#8230; <a href="https://www.sklueh.de/2014/07/sharemysnippets-plugin-fuer-eclipse/" class="more-link"><span class="screen-reader-text">ShareMySnippets Plugin für Eclipse</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>Das ShareMySnippets-Plugin ist eine Erweiterung für <a href="http://www.eclipse.org/" title="Eclipse IDE" target="_blank">Eclipse</a> mit der sich Code-Snippets von <a href="http://share-my-snippets.de" title="Share-My-Snippets.de" target="_blank">Share-My-Snippets.de</a> direkt in die IDE einfügen lassen. Über ein Suchfeld können alle öffentlichen Snippets nach den entsprechenden Begriffen durchsucht werden. </p>
<p><strong>Snippets einfügen:</strong><br />
Über den Menü-Punkt &#8222;Share My Snippets > Browse Snippets&#8220; können die Snippets eingefügt werden:<br />
<a href="https://sklueh.de/wp-content/uploads/2018/12/eclipse-plugin-demo.gif"><img decoding="async" style="border:1px solid black" src="https://sklueh.de/wp-content/uploads/2018/12/eclipse-plugin-demo-300x240.gif" alt="Snippet einfügen" width="300" height="240" class="alignnone size-medium wp-image-1825" /></a><br />
<span id="more-1812"></span></p>
<p><strong>Installation:</strong></p>
<ul>
<li>Menü: Help > Install New Software</li>
<li>Work with: http://share-my-snippets.de/install/</li>
<li>ShareMySnippetsPluginFeature auswählen und dem Setup-Assistenten folgen.</li>
</ul>
<p><a href="https://sklueh.de/wp-content/uploads/2018/12/how-to-install-snippet-eclipse-plugin-compressed2.gif"><img decoding="async" style="border:1px solid black" src="https://sklueh.de/wp-content/uploads/2018/12/how-to-install-snippet-eclipse-plugin-compressed2-300x166.gif" alt="Installieren" width="300" height="166" class="alignnone size-medium wp-image-1814" srcset="https://www.sklueh.de/wp-content/uploads/2018/12/how-to-install-snippet-eclipse-plugin-compressed2-300x166.gif 300w, https://www.sklueh.de/wp-content/uploads/2018/12/how-to-install-snippet-eclipse-plugin-compressed2-1024x568.gif 1024w, https://www.sklueh.de/wp-content/uploads/2018/12/how-to-install-snippet-eclipse-plugin-compressed2-930x515.gif 930w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p><strong>Links</strong><br />
<a href="https://github.com/sklueh/ShareMySnippetsPlugin" title="ShareMySnippetsPlugin" target="_blank">Source Code</a><br />
<a href="http://share-my-snippets.de" title="Share-My-Snippets" target="_blank">Share My Snippets</a><br />
<a href="http://www.eclipse.org/" title="Eclipse IDE" target="_blank">Eclipse</a></p>
<p>Über Anregungen und Verbesserungsvorschläge würde ich mich sehr freuen.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2014/07/sharemysnippets-plugin-fuer-eclipse/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
		<item>
		<title>jQuery Quick-Cache (inkl. Benchmark)</title>
		<link>https://www.sklueh.de/2014/01/jquery-quick-cache-inkl-benchmark/</link>
					<comments>https://www.sklueh.de/2014/01/jquery-quick-cache-inkl-benchmark/#respond</comments>
		
		
		<pubDate>Sat, 25 Jan 2014 12:37:28 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[auto-cache]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[quick-cache]]></category>
		<category><![CDATA[selectors]]></category>
		<guid isPermaLink="false">http://sklueh.de/?p=1744</guid>

					<description><![CDATA[Sobald das DOM etwas umfangreicher ist, sollten so viele jQuery-Objekte wie möglich gecached werden. Da sonst Performance-Problemen im JavaScript-Code auftreten können. Der nachfolgende Code zeigt, wie ein einfacher Caching-Mechanismus für jQuery umgesetzt werden kann. Code: var oCache = &#123;&#125;; function $$&#40;sSelector&#41; &#123; &#160; if&#40;!oCache.hasOwnProperty&#40;sSelector&#41;&#41; &#160; oCache&#91;sSelector&#93; = $&#40;sSelector&#41;; &#160; return oCache&#91;sSelector&#93;; &#125;; Beispiel: $$&#40;'.myclass'&#41;.text&#40;&#34;Blaaaa&#34;&#41;; &#160;//jQuery-Objekt &#8230; <a href="https://www.sklueh.de/2014/01/jquery-quick-cache-inkl-benchmark/" class="more-link"><span class="screen-reader-text">jQuery Quick-Cache (inkl. Benchmark)</span> weiterlesen</a>]]></description>
										<content:encoded><![CDATA[<p>Sobald das DOM etwas umfangreicher ist, sollten so viele jQuery-Objekte wie möglich gecached werden. Da sonst Performance-Problemen im JavaScript-Code auftreten können. Der nachfolgende Code zeigt, wie ein einfacher Caching-Mechanismus für jQuery umgesetzt werden kann.</p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000066; font-weight: bold;">var</span> oCache <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">function</span> $$<span style="color: #009900;">&#40;</span>sSelector<span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>oCache.<span style="color: #000066;">hasOwnProperty</span><span style="color: #009900;">&#40;</span>sSelector<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; oCache<span style="color: #009900;">&#91;</span>sSelector<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>sSelector<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">return</span> oCache<span style="color: #009900;">&#91;</span>sSelector<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p><span id="more-1744"></span><br />
<strong>Beispiel:</strong></p>
<div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">$$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.myclass'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Blaaaa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #006600; font-style: italic;">//jQuery-Objekt ('.myclass') in Cache ablegen</span><br />
$$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.myclass'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Bluuuuub&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//jQuery-Objekt ('.myclass') aus Cache verwenden</span></div></div>
<p><strong>Benchmark:</strong><br />
Der Benchmark zeigt, dass die Verwendung des Caches einen deutlichen Performance-Gewinn bringt.</p>
<div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">//without_cache: 430.7ms</span><br />
console.<span style="color: #660066;">time</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'without_cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">10000</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.test'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Blaaaa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<span style="color: #009900;">&#125;</span><br />
console.<span style="color: #660066;">timeEnd</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'without_cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//with_cache: 241.55ms</span><br />
console.<span style="color: #660066;">time</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'with_cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">10000</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.test'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Blaaaa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<span style="color: #009900;">&#125;</span><br />
console.<span style="color: #660066;">timeEnd</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'with_cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sklueh.de/2014/01/jquery-quick-cache-inkl-benchmark/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<dc:creator>Sebastian Klüh</dc:creator></item>
	</channel>
</rss>