<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Method Details</title>
<link rel="stylesheet" type="text/css" media="screen" href="style.css">
<script name="javascript">
function show_hide_examples(mode)
{
if (document.getElementById("examples").style.display == "none")
{
document.getElementById("examples").style.display = "";
}
else
{
document.getElementById("examples").style.display = "none";
}
}
</script>
</head>
<body>
<div id="outer">
<h1 id="head">
<span>Method:
PHPCrawler::initChildProcess()</span>
</h1>
<h2 id="head">
<span><a href="overview.html"><< Back to class-overview</a></span>
</h2>
<br>
<div id="section">
Overridable method that will be called by every used child-process just before it starts the crawling-procedure.
</div>
<div id="section">
<b>Signature:</b>
<p id="signature">
public initChildProcess()
</p>
</div>
<div id="section">
<b>Parameters:</b>
<p>
<table id="param_list">
<tr><td><i>No parameter-descriptions available.</i></td></td>
</table>
</p>
</div>
<div id="section">
<b>Returns:</b>
<p>
<table id="param_list">
<tr><td><i>No information</i></td></tr>
</table>
</p>
</div>
<div id="section">
<b>Description:</b>
<p>
Every child-process of the crawler will call this method just before it starts it's crawling-loop from within it's<br>process-context.<br><br>So when using the multi-process mode "<a href="../PHPCrawlerMultiProcessModes/constant_detail_tpl_constant_MPMODE_CHILDS_EXECUTES_USERCODE.htm" class="inline">PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE</a>", this method<br>should be overidden and used to open any needed database-connections, file streams or other similar handles to ensure<br>that they will get opened and accessible for every used child-process.<br><br>Example:<code>class MyCrawler extends PHPCrawler <br>{<br> protected $mysql_link;<br><br> function initChildProcess()<br> {<br> // Open a database-connection for every used process<br> $this->mysql_link = mysql_connect("myhost", "myusername", "mypassword");<br> mysql_select_db ("mydatabasename", $this->mysql_link);<br> }<br><br> function handleDocumentInfo($PageInfo) <br> {<br> mysql_query("INSERT INTO urls SET url = '".$PageInfo->url."';", $this->mysql_link);<br> }<br>}<br><br>// Start crawler with 5 processes<br>$crawler = new MyCrawler();<br>$crawler->setURL("http://www.any-url.com");<br>$crawler->goMultiProcessed(5, PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE);</code>
</p>
</div>
</div>
<div id="footer">Docs created with <a href="http://phpclassview.cuab.de" target="_parent">PhpClassView</a></div>
</body>
</html>