You need to sign in to do that
Don't have an account?
CakePHP example Data source for Enterprise
I have built a sample way to integrate the Salesforce API with CakePHP.
The zip package is at http://www.contangoadvisors.com/work/SalesforceCakePHPdatasource.zip
This Datasource is for a Salesforce Enterprise implementation
to use the other types you will have to modify the code.
This Package requires you to have the Salesforce PHP Toolkit 13.0 or greater.
(http://wiki.developerforce.com/index.php/PHP_Toolkit)
I wrote this as a simple implementation of the Salesforce enterprise API for read and login
!!!!THIS PACKAGE IS NOT COMPLETE USE AS A STARTING POINT!!!!
You will want to extend the salesforce_source.php file with other methods for "upsert", "delete", etc.
(SEE NEXT MESSAGE: I have updated the code to support all of the WSDL functions including any that will be changed or added it is now included in the zip)
How to install this package:
1. Bake a CakePHP app ( see CakePHP.org) "app" refers your newly baked application's directory
2. Place the following files in your App.
models/datasources/salesforce_source.php in app/models/datasources/ (replace with salesforce_source.php in next message it is now included in the zip)
config/database.php in app/config/
models/account.php in app/models/ (use below if using new salesforce_source.php in next message now included in the zip)
<?php
class Account extends AppModel {
var $useDbConfig='sftest';
var $useTable = false;
function first10account() {
$SOQL = "SELECT
a.AccountNumber,
a.AnnualRevenue,
a.BillingCity,
a.BillingCountry,
a.BillingPostalCode,
a.BillingState,
a.BillingStreet,
a.CreatedById,
a.CreatedDate,
a.Description,
a.Fax,
a.FirstName,
a.Id,
a.Industry,
a.IsDeleted,
a.IsPersonAccount,
a.LastActivityDate,
a.LastModifiedById,
a.LastModifiedDate,
a.LastName,
a.MasterRecordId,
a.Name,
a.NumberOfEmployees,
a.OwnerId,
a.Ownership,
a.ParentId,
a.Phone,
a.Rating,
a.RecordTypeId,
a.Salutation,
a.Type,
a.Website
FROM Account a
WHERE IsDeleted = Null
Limit 10";
return $this->query(array('query',$SOQL)); // changed to support new datasource
}
}
?>
controllers/mytest_controller.php in app/controllers/
views/mytest directory in app/views/
Your copy of the Salesforce PHP Toolkit "soapclient/" directory is placed in app/models/datasources/
3. Download your enterprise.wsdl.xml from your Production salesforce instance
4. Download your enterprise.wsdl.xml from your Sandbox salesforce instance and name it test.enterprise.wsdl.xml
5. copy your enterprise.wsdl.xml and test.enterprise.wsdl.xml to app/models/datasources/soapclient
6. Edit your app/config/database.php add your usernames and passwords for BOOTH Instances.
(change sflive to default if needed.)
You can then test your connection by going to your new cake app in a web browser:
http://URL_OF_YOUR_CAKE_INSTANCE/mytest
you should see the first 10 accounts on your test instance of salesforce.
The Model for account SOBJ (app/models/account.php) contains a SOQL query.
The controller (app/controllers/mytest_controller.php) gets the result of the query method in the model and passes it to the view.
The View (app/views/mytest/index.ctp) iterates through the query result and displays the data in a table.
The Data source "salesforce_source.php" has been updated to support ALL wsdl methods using Query function.
The following is an example call to this from a Model using the test connector in the database.conf:
Note the $this->query(array('methodname', data1, data2, data 3);
Here is a call using the Upsert method from a controller:
The above uses a modified version of the SforceEnterpriseClient.php that changes upsert method to be more PHP rational.
mod to upsert follows:
Here is the new salesforce_source.php
Hii Cwestonr,
Can you plz post the modified code also for create methos ad you posted for upsert method as soon as possible??,,,