+ Start a Discussion

Connecting PHP website with SFDC database

Hello Wonderful People,


I am somewhat of a newbie to this so I apologize if I ask some dumb questions - I've tried to review info about Force.com, PHP toolkit, etc. but it's just sort of confusing me right now as I don't have the strongest technical background (yet).


Basically, I'm programming a PHP website that is currently connected to a MySQL database, which stores all account and contact information (including each user's login info). The MySQL database also stores user-specific information (e.g. everything they've bought from us) that we currently display back to them when they go to the "My Account" page of our website.


I have also recently worked with SFDC and got my ADM 201 certification, so I'm just now realizing how powerful it is. I would love to start using SFDC with my website but I'm not sure where to begin - ideally, I'd want the SFDC database to replace everything that is held in MySQL right now so I only need to interact with one DB in the future.


I would like it to capture a user's account information (which I understand I can use Web-to-Lead), other user preference (which can perhaps also be stored in the leads or contacts table), and also be able to display SFDC database information back to the user on our website. Basically, I would just need to know how to read and write using PHP from a SFDC database as the rest of the programming logic is already in place....


My questions are does it even sound feasible for my website to solely interact with a SFDC database (so that I don't need to use MySQL anymore)? If so, what are the tools and concepts I need to understand?


 Would be much appreciated if you can get me started down the right path.







There is very good documentation to get you started building a site that connects to PHP.





In particular the samples show how to do most things you will want to do.




I use the partner API for all my web development.


Of course, you will need to have experience with PHP programming, connecting to databases (e.g. MySQL) and using DB backends for forms, plus some understanding of object-oriented PHP. If you're not there yet, you'd need to get there first to take advantage of this documentation. If you are, you should be able to go through and try out all the samples with your own SF account and that will take you pretty far with what you're trying to do.


I'd come back to the forum for help when you have specific questions, e.g. error messages, or why is this code giving me this unexpected response, etc. Of course, search first, because many of the problems you'll run into have already been addressed here.


Good luck,




Thank you fro your reply. I am there in terms of knowing how to do everything with PHP and MySQL, so hopefully reviewing the documents you pointed me to will give me the knowledge to connect my website with SFDC.


Just as a double check - is it feasible then for me to eventually completely replace my current MySQL database with SFDC's database in the cloud? I would love if my website only needed to interact with one database as I don't want to be maintaining data in 2 separate places... (How do you develop your websites that need to connect to a back-end DB? Do you only connect it to the Salesforce DB and not use MySQL at all?)


Thanks a lot!!





No, I use both. I mainly use SF for CRM data that users need to interact with and manage on their own using the SF GUI - esp. contact and accounts - but have used it with many custom objects. For example I built an event management system which connects RSVP data from forms to existing contacts, to track when contacts attend events, as well as many other custom objects. You need to look at the particular application to decide whether your users will need to interact with the data and whether SF makes it easier for them to do that.


There are other considerations also. Communicating with a local MySQL DB is generally going to be much faster than SF, because it's not going through web services and it's been optimized for that.


Salesforce also has API call limits, based on how many user licenses you buy.





If you have high volume, then going with the PHP API for your sole DB backend probably isn't an option. On my RSVP system I use a hybrid approach with a MySQL db for all the info shown on the site, and sending user input back to SF, but my setup also involves some Apex & Visualforce.




Thanks for you post here ptepper. However, my question is where do I get all the fils that are referesed in the getting starte page. For instance,

SforceEnterpriseClient.php. As I understand it they need to reside on my server. Correct?