View Single Post
  #1  
Old 08-09-2007, 11:44 AM
mike mike is offline
Administrator
 
Join Date: May 2007
Posts: 273
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike
Salesforce PHP MySQL Database Replication Tool

Here is the MySQL version of the Database replication Tool. This new script takes parameters from a web form and will create your MySQL tables/objects via the API. All you have to supply is the following:

* You're Salesforce Username
* You're Salesforce Password
* Table Prefix (e.g. sforce_ ) not required
* MySQL Database Name
* MySQL User Name
* MySQL Password

David Clairborne recently released a tool that will create the schema that a user could copy and paste from a web browser for MySQL and I added the process of creating the tables in MySQL . This new script will not only create that same file, but it will login to your MySQL database and create the tables for you.

This script was developed against a new developers account and it works without any hiccups. It has also been tested against a real live org, a sandbox, and a modified developers account. I do not see why it would not work against anyone's or any company's live instance.

If you plan on using this script to test it out, there are a few lines of code that need to be checked so they match your paths of the following scripts from the PHP toolkit:

Check line number 26 & 27 and make sure you correct the path to the following:

PHP Code:
require_once ('./includes/soapclient/SforcePartnerClient.php');
require_once (
'./includes/soapclient/SforceHeaderOptions.php'); 
and line number > 53
PHP Code:
$wsdl './includes/soapclient/partner.wsdl.xml'

If you forget to modify these lines, the script will fail. This takes into account that the table names and field names in MySQL has some reserved words that conflict with the Object names in Salesforce, so you will need to check your table names once the script is complete. These two words are the Objects Group and Case. There are field names which are in salesforce that have this same exact name. Here is what I did to check this and change the name to Group__C and Case__C.

Note: This change to the tables names on happens if you decide not to use a prefix (e.g. sforce_) on the form




If you wish to obtain the SQL file that is also created to this, it will be located in the same folder as this script runs in and is called:

Code:

salesforce_mysql.sql


This script uses ADOdb to connect to MySQL; you MUST be using this database class in order for this script to work, if you do not, THE SCRIPT WILL FAIL.

You can download the ADOdb package from the main menu on my home page. This package was developed to work with:

Apache
MySQL 10g
PHP 5.*

If you have any questions please feel free to use the contact form on this site and I will do my best to get back to you ASAP!



Thanks,
Mike
Attached Files
File Type: zip salesforce_mysql_build_100.zip (3.2 KB, 311 views)
Reply With Quote