The following script is the simple example to understand the process of importing the data from your Salesforce object to the MySQL database:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
define(BASEDIR, 'lib/phptoolkit/soapclient/');
require_once (BASEDIR.'SforcePartnerClient.php');
require_once (BASEDIR.'SforceHeaderOptions.php');
require_once ('adodb/adodb.inc.php');
$db = NewADOConnection('mysql');
$db->Connect("localhost", "Username", "password", "TargetDatabaseName");
$wsdl = BASEDIR.'partner.wsdl.xml';
$userName = "user@somemail.sth";
$password = "passwordsecuritycode";
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);
$query = "Select Id,Name FROM Organization";
$response = $client->query($query);
echo '<p>Importing organizations From Salesforce...</p>';
foreach ($response->records as $r)
{
$pass_this['Id'] = $r->Id;
$pass_this['Name'] = addslashes($r->fields->Name);
$sql = $db->execute("INSERT INTO sforce_organization (id,name)
VALUES ('{$pass_this['Id']}','{$pass_this['Name']}' )");
}
echo '<p>Importing organizations From Salesforce Completed.</p>';
?>
Things to remember here are:
1. Configuring PHP
2. There is option of Parter WSDL and Enterprise WSDL to be used. I’ve used the Partner WSDL as it supports for the applications that are metadata driven.
See here for more about these WSDL http://www.salesforce.com/us/developer/docs/sforce70/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sforceAPI_WWHelp&file=sforce_API_partner_intro.html