Method: PHPCrawler::initChildProcess()



Overridable method that will be called by every used child-process just before it starts the crawling-procedure.
Signature:

public initChildProcess()

Parameters:

No parameter-descriptions available.

Returns:

No information

Description:

Every child-process of the crawler will call this method just before it starts it's crawling-loop from within it's
process-context.

So when using the multi-process mode "PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE", this method
should be overidden and used to open any needed database-connections, file streams or other similar handles to ensure
that they will get opened and accessible for every used child-process.

Example:class MyCrawler extends PHPCrawler
{
  protected $mysql_link;

  function initChildProcess()
  {
    // Open a database-connection for every used process
    $this->mysql_link = mysql_connect("myhost", "myusername", "mypassword");
    mysql_select_db ("mydatabasename", $this->mysql_link);
  }

  function handleDocumentInfo($PageInfo)
  {
    mysql_query("INSERT INTO urls SET url = '".$PageInfo->url."';", $this->mysql_link);
  }
}

// Start crawler with 5 processes
$crawler = new MyCrawler();
$crawler->setURL("http://www.any-url.com");
$crawler->goMultiProcessed(5, PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE);