PDO (PHP Data Objects) Is Not a Fluent Interface

Problem

PDO does not provide a fluent interface contrary to the claims of many.  It is deceiving because it looks like a fluent interface on the surface due to its support of method chaining on some objects.  However, PDO doesn't even support method chaining properly.  It does not consistently throw exceptions and instead often uses return values of false to indicate failure.  PDO::query in particular leaves you with a "Fatal error: (method name) method called on non-object" when an error occurs.

View Solution: PDO (PHP Data Objects) Is Not a Fluent Interface

PHP: Salesforce Object Type Determination by Key Prefix

Problem

If you export your data from Salesforce you will find yourself with a bunch of cross-relationships and no idea of how to map them.  For example, a dump of Documents will give you a list of object IDs each document is related to.  You might look at that and find yourself lost or sifting through data in dozens of tables.  No need for all of that.  Salesforce adds what they call a keyPrefix to every Object ID.  This is used to instantiate the correct object type for that ID.  If, in your code, you would like to build a factory to realize objects from serialized Salesforce data dumps you need a mapping function that reads the keyPrefix and instantiates the correct object in your code.

View Solution: PHP: Salesforce Object Type Determination by Key Prefix

PHP: Salesforce Conversion to 18 Character from 15 Character Id

Problem

If you run reports in Salesforce you can only see a 15 character Id field.  If you request a dump or access the API with case insensitive Id fields enabled you see an 18 character Id.  Obviously, you may be doing both and need to correlate the Id fields.

Salesforce Id fields are 15 character base62 encoded case sensitive strings.  SQL databases such as MySQL and Microsoft SQL as well as many applications such as Microsoft Excel treat primary keys as case insensitive.  To overcome this limitation Salesforce appends a 3 character checksum-like sequence which is designed to make the string case insensitive.

View Solution: PHP: Salesforce Conversion to 18 Character from 15 Character Id