Login   Register  
PHP Classes
elePHPant
Icontem

File: docs/MySQLib/mysql_parser.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Martin Brommer  >  MySQL Parser  >  docs/MySQLib/mysql_parser.html  >  Download  
File: docs/MySQLib/mysql_parser.html
Role: Documentation
Content type: text/plain
Description: Part of the documentation
Class: MySQL Parser
Converts boolean expressions into MySQL conditions
Author: By
Last change:
Date: 10 years ago
Size: 11,226 bytes
 

Contents

Class file image Download
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs For Class mysql_parser</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
			<div class="page-body">			
<h2 class="class-name">Class mysql_parser</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
													<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
						|											<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
						
			</div>
	<div class="info-box-body">
		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Parser class that parser boolean strings (item1 AND item2 AND NOT (item3 OR item4)) into strings that can be used in MySQL MyIsam fulltext searches (+item1 +item2 -(item3 item4))</p>
<p class="description"><p>Example: <pre><code><pre>	
// If you want to do one-time parsing:
$query = "item1 OR item2 AND (item3 AND item4 NOT (item5 OR item6))";
$parser = new mysql_parser($query);
echo $parser->result;
// This should echo "item1 item2 +(+item3 +item4 -(item5 item6 ))"

// I made some changes to be able to parse multiple strings, I didn't 
// actually need it when writing the class, so it is a bit of a late addition:
$queries = array(
	"item1 OR item2 AND (item3 AND item4 NOT (item5 OR item6))",
	"NOT item1 OR item2 AND (item3 OR item4)"
		);
foreach ($queries as $query)
		{
		echo $parser->parse($parser->atomize($query));
		}</pre></code></pre></p></p>
	<ul class="tags">
				<li><span class="field">todo:</span> better suport for multiple parses</li>
				<li><span class="field">todo:</span> Fix bug in atomize function, it works but somehow comes back with an extra space</li>
			</ul>
		<p class="notes">
			Located in <a class="field" href="_parser_class_php.html">/parser.class.php</a> (line <span class="field">39</span>)
		</p>
		
				
		<pre></pre>
	
			</div>
</div>


	<a name="sec-var-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Variable Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
						<span class="disabled">Vars</span> (<a href="#sec-vars">details</a>)
							| 
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
							
					</div>
		<div class="info-box-body">
			<div class="var-summary">
								<div class="var-title">
					<span class="var-type">array</span>
					<a href="#$atoms" title="details" class="var-name">$atoms</a>
				</div>
								<div class="var-title">
					<span class="var-type">array</span>
					<a href="#$log" title="details" class="var-name">$log</a>
				</div>
								<div class="var-title">
					<span class="var-type">array</span>
					<a href="#$reserved" title="details" class="var-name">$reserved</a>
				</div>
								<div class="var-title">
					<span class="var-type">array</span>
					<a href="#$result" title="details" class="var-name">$result</a>
				</div>
							</div>
		</div>
	</div>

	<a name="sec-method-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Method Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
															<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
				 
				|
						<span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
		</div>
		<div class="info-box-body">			
			<div class="method-summary">
								
				<div class="method-definition">
											<span class="method-result">mysql_parser</span>
										<a href="#mysql_parser" title="details" class="method-name">mysql_parser</a>
											([<span class="var-type">string</span>&nbsp;<span class="var-name">$query</span> = <span class="var-default">''</span>])
									</div>
								
				<div class="method-definition">
											<span class="method-result">array</span>
										<a href="#atomize" title="details" class="method-name">atomize</a>
										()
									</div>
								
				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#error" title="details" class="method-name">error</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$msg</span>)
									</div>
								
				<div class="method-definition">
											<span class="method-result">string</span>
										<a href="#parse" title="details" class="method-name">parse</a>
											(<span class="var-type">array</span>&nbsp;<span class="var-name">$atoms</span>)
									</div>
							</div>
		</div>
	</div>		

	<a name="sec-vars"></a>
	<div class="info-box">
		<div class="info-box-title">Variables</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
										<a href="#sec-var-summary">Vars</a> (<span class="disabled">details</span>)
						
			
							| 
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
							
					</div>
		<div class="info-box-body">
			<a name="var$atoms" id="$atoms"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$atoms</span>
			 = <span class="var-default">array()</span>			(line <span class="line-number">42</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	<ul class="tags">
				<li><span class="field">var:</span> <ul><li>The 'atomized' string used as intermediate</li></ul></li>
			</ul>
	
	
		
		

</div>
<a name="var$log" id="$log"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$log</span>
			 = <span class="var-default">array()</span>			(line <span class="line-number">63</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	<ul class="tags">
				<li><span class="field">var:</span> <ul><li>Any errors / warnings raised during processing</li></ul></li>
			</ul>
	
	
		
		

</div>
<a name="var$reserved" id="$reserved"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$reserved</span>
			 = <span class="var-default">array('or' =&gt; '', <br />						'and' =&gt; '+', <br />						'not' =&gt; '-')</span>			(line <span class="line-number">50</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	<ul class="tags">
				<li><span class="field">var:</span> <ul><li>Boolean keywords to be parsed</li></ul></li>
			</ul>
	
	
		
		

</div>
<a name="var$result" id="$result"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$result</span>
			 = <span class="var-default">array()</span>			(line <span class="line-number">46</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	<ul class="tags">
				<li><span class="field">var:</span> <ul><li>Array of processed 'atoms'</li></ul></li>
			</ul>
	
	
		
		

</div>
						
		</div>
	</div>
	
	<a name="sec-methods"></a>
	<div class="info-box">
		<div class="info-box-title">Methods</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
															<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
														<a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)
						
		</div>
		<div class="info-box-body">
			<A NAME='method_detail'></A>
<a name="methodmysql_parser" id="mysql_parser"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<span class="method-title">Constructor mysql_parser</span> (line <span class="line-number">73</span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">constructor</p>
	
	<div class="method-signature">
		<span class="method-result">mysql_parser</span>
		<span class="method-name">
			mysql_parser
		</span>
					([<span class="var-type">string</span>&nbsp;<span class="var-name">$query</span> = <span class="var-default">''</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$query</span><span class="var-description">: the query string to be parsed</span>			</li>
				</ul>
		
		
	</div>
<a name="methodatomize" id="atomize"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<span class="method-title">atomize</span> (line <span class="line-number">96</span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Parse the string into an array of 'atoms'</p>
	
	<div class="method-signature">
		<span class="method-result">array</span>
		<span class="method-name">
			atomize
		</span>
				()
			</div>
	
		
		
	</div>
<a name="methoderror" id="error"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<span class="method-title">error</span> (line <span class="line-number">86</span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Write an error / warning to the array.</p>
	
	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			error
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$msg</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$msg</span>			</li>
				</ul>
		
		
	</div>
<a name="methodparse" id="parse"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<span class="method-title">parse</span> (line <span class="line-number">133</span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Parse an array of 'atoms' into a mysql compatible string</p>
	
	<div class="method-signature">
		<span class="method-result">string</span>
		<span class="method-name">
			parse
		</span>
					(<span class="var-type">array</span>&nbsp;<span class="var-name">$atoms</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">array</span>
				<span class="var-name">$atoms</span>			</li>
				</ul>
		
		
	</div>
						
		</div>
	</div>
	
	<p class="notes" id="credit">
		Documentation generated on Fri, 27 Feb 2004 19:55:41 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.2</a>
	</p>
	</div></body>
</html>