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

<channel>
	<title>Benjamin Mock &#187; mysql</title>
	<atom:link href="http://benjaminmock.de/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://benjaminmock.de</link>
	<description>web &#38; mobile development</description>
	<lastBuildDate>Tue, 08 Nov 2011 16:20:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>MySQL Tabelle kopieren / synchronisieren</title>
		<link>http://benjaminmock.de/mysql-tabelle-kopieren-synchronisieren/</link>
		<comments>http://benjaminmock.de/mysql-tabelle-kopieren-synchronisieren/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 02:01:49 +0000</pubDate>
		<dc:creator>Benjamin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sync]]></category>

		<guid isPermaLink="false">http://benjaminmock.de/?p=176</guid>
		<description><![CDATA[Der einfachste Weg eine Datenbank anhand einer anderen zu synchronisieren ist, sie einfach zu kopieren. Das kann man über den Umweg eines Dumps machen, oder direkt über eine Pipe. Zwar handelt es sich dabei nicht um eine echte Synchronisation, da alle Daten gelöscht und neu erstellt werden, aber dieses Vorgehen funktioniert schnell und unkompliziert. mysqldump [...]]]></description>
			<content:encoded><![CDATA[<p>Der einfachste Weg eine Datenbank anhand einer anderen zu synchronisieren ist, sie einfach zu kopieren. Das kann man über den Umweg eines Dumps machen, oder direkt über eine Pipe. Zwar handelt es sich dabei nicht um eine echte Synchronisation, da alle Daten gelöscht und neu erstellt werden, aber dieses Vorgehen funktioniert schnell und unkompliziert.</p>
<pre><code>
mysqldump -al --user=[username1] --password=[pw1] -h [host1] --add-drop-table [db_name1] [table] | mysql -h [host2] --user=[username2] --password=[pw2] [db_name2]
</code></pre>
<p>Alles mit [*] muss natürlich entsprechend ersetzt werden (auch die Klammern entfernen!).</p>
]]></content:encoded>
			<wfw:commentRss>http://benjaminmock.de/mysql-tabelle-kopieren-synchronisieren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter Suchmaschine mit Lucene aus dem Zend-Framework</title>
		<link>http://benjaminmock.de/codeigniter-suchmaschine-mit-lucene-aus-dem-zend-framework/</link>
		<comments>http://benjaminmock.de/codeigniter-suchmaschine-mit-lucene-aus-dem-zend-framework/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 19:03:23 +0000</pubDate>
		<dc:creator>Benjamin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[suchmaschine]]></category>
		<category><![CDATA[volltextsuche]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://benjaminmock.de/?p=56</guid>
		<description><![CDATA[Um eine ordentliche Suchfunktion in das eigene Web-Projekt zu integrieren bedarf es entweder einer Menge Arbeit oder der Nutzung von Lucene. Bei Lucene handelt es sich um eine plattformunabhängige Such- und Index-Programmierschnittstelle der Apache Software Foundation. Die Wikipedia setzt beispielsweise Lucene zur Volltextsuche ein. Der einfachste Weg Lucene in CodeIgniter zu integrieren ist die Verwendung [...]]]></description>
			<content:encoded><![CDATA[<p>Um eine ordentliche Suchfunktion in das eigene Web-Projekt zu integrieren bedarf es entweder einer Menge Arbeit oder der Nutzung von <a href="http://lucene.apache.org/java/docs/index.html">Lucene</a>. Bei Lucene handelt es sich um eine plattformunabhängige Such- und Index-Programmierschnittstelle der Apache Software Foundation. Die Wikipedia setzt beispielsweise Lucene zur Volltextsuche ein.</p>
<p>Der einfachste Weg Lucene in CodeIgniter zu integrieren ist die Verwendung der Zend-Lucene-Bibliothek. Dazu gibt es ein gutes Tutorial von <a href="http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/">Fred Wu</a>, das ich hier kurz zusammenfassen und um die Suchfunktionalität erweitern werde.</p>
<h2>Zend-Bibliotheken in CodeIgniter integrieren</h2>
<ol>
<li>Aktuelle Version des Zend-Frameworks <a href="http://framework.zend.com/download/current/">hier</a> herunterladen</li>
<li>Paket entpacken und den Ordner <strong>Zend</strong> (unter <strong>Library</strong>) in das CodeIgniter-Verzeichnis <strong>application/libraries/</strong> kopieren</li>
<li>Das unten angegebene Script in das gleiche Verzeichnis kopieren(<strong>application/libraries/</strong>)</li>
</ol>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre>
</td>
<td class="code">
<pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
* Zend Framework Loader
*
* Put the 'Zend' folder (unpacked from the Zend Framework package, under 'Library')
* in CI installation's 'application/libraries' folder
* You can put it elsewhere but remember to alter the script accordingly
*
* Usage:
*   1) $this-&amp;gt;load-&amp;gt;library('zend', 'Zend/Package/Name');
*   or
*   2) $this-&amp;gt;load-&amp;gt;library('zend');
*      then $this-&amp;gt;zend-&amp;gt;load('Zend/Package/Name');
*
* * the second usage is useful for autoloading the Zend Framework library
* * Zend/Package/Name does not need the '.php' at the end
*/</span>
<span style="color: #000000; font-weight: bold;">class</span> CI_Zend
<span style="color: #009900;">&#123;</span>
<span style="color: #009933; font-style: italic;">/**
* Constructor
*
* @param	string $class class name
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// include path for Zend Framework</span>
<span style="color: #666666; font-style: italic;">// alter it accordingly if you have put the 'Zend' folder elsewhere</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'include_path'</span><span style="color: #339933;">,</span>
<span style="color: #990000;">ini_get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'include_path'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span> APPPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'libraries'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;&lt;/</span>code<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>code<span style="color: #339933;">&gt;</span>if <span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$class</span> <span style="color: #339933;">.</span> EXT<span style="color: #339933;">;</span>
log_message<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'debug'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Zend Class <span style="color: #006699; font-weight: bold;">$class</span> Loaded&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
log_message<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'debug'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Zend Class Initialized&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
* Zend Class Loader
*
* @param	string $class class name
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> load<span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$class</span> <span style="color: #339933;">.</span> EXT<span style="color: #339933;">;</span>
log_message<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'debug'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Zend Class <span style="color: #006699; font-weight: bold;">$class</span> Loaded&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre>
</td>
</tr>
</table>
</div>
<p>Das war&#8217;s schon! Damit können jetzt die Bibliotheken des Zend-Frameworks in CodeIgniter genutzt werden. Man lädt die Bibliotheken folgendermaßen:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
</pre>
</td>
<td class="code">
<pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'zend'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">zend</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Zend/Name_der_Bibliothek'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</td>
</tr>
</table>
</div>
<p>Die Endung .php wird bei der Angabe des Bibliotheksnamen nicht benötigt.</p>
<h3>Suchfunktionalität mittels Lucene in Codeiginter integrieren</h3>
<p>Da jetzt die Zend-Bibliotheken in CodeIgniter nutzbar sind, steht einer Nutzung von Lucene ebenfalls nicht mehr im Weg. Schauen wir uns einmal den dazu benötigten Controller an (suche.php):</p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre>
</td>
<td class="code">
<pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Suche <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> Suche<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		parent<span style="color: #339933;">::</span><span style="color: #004000;">Controller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Zends Lucene-Bibliothek laden</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'zend'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">zend</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Zend/Search/Lucene'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Suchindex festelegen</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">search_index</span> <span style="color: #339933;">=</span> APPPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'search/index'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'search_view'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index_it<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Index erstellen (bisheriger Index wird gelöscht)</span>
		<span style="color: #000088;">$index</span> <span style="color: #339933;">=</span> Zend_Search_Lucene<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">search_index</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Content, der indexiert werden soll aus DB auslesen</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'brand_content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Alle Content-Instanzen zum Index hinzufügen</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Lucene Document für diese Content-Instanz erstellen</span>
			<span style="color: #000088;">$doc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Search_Lucene_Document<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// dieser Titel wird in den Suchergebnissen angezeigt</span>
			<span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span>Zend_Search_Lucene_Field<span style="color: #339933;">::</span><span style="color: #004000;">Text</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</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;">// mit diesem Pfad werden die Suchergebnisse verknüpft</span>
			<span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span>Zend_Search_Lucene_Field<span style="color: #339933;">::</span><span style="color: #004000;">Text</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'path'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/brand/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slug</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</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;">// dieser Inhalt wird neben dem Titel indexiert</span>
			<span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span>Zend_Search_Lucene_Field<span style="color: #339933;">::</span><span style="color: #004000;">UnStored</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// zum Index hinzufügen</span>
			<span style="color: #000088;">$index</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addDocument</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$doc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Added '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$article</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' to index.&lt;br /&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$index</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">optimize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> result<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'results'</span><span style="color: #009900;">&#93;</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>
&nbsp;
		<span style="color: #666666; font-style: italic;">// falls der &quot;search_query&quot;-Parameter übergeben wurde Suche ausführen</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'search_query'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Index analysieren; Suchergebnisse auslesen</span>
			<span style="color: #000088;">$index</span> <span style="color: #339933;">=</span> Zend_Search_Lucene<span style="color: #339933;">::</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">search_index</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'results'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$index</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'search_query'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">// View mit Suchergebnissen anzeigen</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'search_view'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</td>
</tr>
</table>
</div>
<p>Im Konstruktor wird die Lucene-Bibliothek wie bereits gezeigt geladen und der Ort des Suchindexes festegelegt. Mit der Funktion <strong>index_it</strong> wird der Index aufgebaut. Diese Funktion hat natürlich nichts in einem öffentlich zugänglichen Controller verloren und ist hier nur aus Gründen der Einfachheit im Controller enthalten.</p>
<p>Die View, die von diesem Controller aufgerufen wird enthält ein Formular mit einem Feld Namens <strong>search_query</strong>. Dieses muss wie bei CodeIgniter üblich per <strong>POST</strong> an suche/result/ übergeben werden, wo die Auswertung des Indexes stattfindet. Die View folgt hier noch einmal kurz im Überblick (search_view.php).</p>
<p> </p>
<div class="wp_syntax">
<table>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre>
</td>
<td class="code">
<pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Suche&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&nbsp;
&lt;h1&gt;Suche&lt;/h1&gt;
&nbsp;
&lt;?php if (empty($_POST['search_query'])):?&gt;
&nbsp;
&lt;p&gt;Bitte Suchbegriff eingeben!&lt;/p&gt;
&lt;form method=&quot;post&quot; action=&quot;&lt;?=base_url()?&gt;suche/result/&quot;&gt;
  &lt;input type=&quot;text&quot; name=&quot;search_query&quot; value=&quot;&quot; size=&quot;40&quot; maxlength=&quot;40&quot;/&gt;
  &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;suchen&quot;/&gt;
&lt;/form&gt;
&nbsp;
&lt;?php else:?&gt;
	&lt;?php if (count($results)):?&gt;
&lt;p&gt;&lt;?php echo count($results) ?&gt; Ergebnis(se) f&amp;uuml;r die Suchanfrage &lt;b&gt;&lt;?php echo $_POST['search_query'];?&gt;&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
	&lt;?php foreach($results as $result):?&gt;
	&lt;li&gt;&lt;?=anchor(site_url($result-&gt;path), $result-&gt;title);?&gt; (&lt;?php echo round($result-&gt;score, 2) * 100;?&gt;%)&lt;/li&gt;
	&lt;?php endforeach;?&gt;
&lt;/ul&gt;
	&lt;?php else:?&gt;
&lt;p&gt;Keine Ergebnisse f&amp;uuml;r die Suchanfrage &lt;b&gt;&lt;?php echo $_POST['search_query'];?&gt;&lt;/b&gt;&lt;/p&gt;
	&lt;?php endif;?&gt;
&lt;?php endif;?&gt;
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre>
</td>
</tr>
</table>
</div>
<p> </p>
<p>Fragen und Anregungen oder Verbesserungsvorschläge zu diesem Code können natürlich gerne in den Kommentaren abgegeben werden.</p>
<p>Sollten Sie einen <a href="http://benjaminmock.de/codeigniter-entwickler/">CodeIgniter-Entwickler</a> für eines Ihrer Projekte suchen, dürfen Sie mich gerne kontaktieren!</p>
]]></content:encoded>
			<wfw:commentRss>http://benjaminmock.de/codeigniter-suchmaschine-mit-lucene-aus-dem-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

