Obama '08

               
   

Go Back   Mike Simonds > Salesforce > Salesforce Coding Discussions

This is a discussion on Using String or float on Numeric Fields in Salesrforce with PHP within the Salesforce Coding Discussions forums, part of the Salesforce category; I was working on this script over the past few days and

Reply
 
LinkBack Thread Tools Rate Thread
  #1  
Old 07-30-2007, 03:12 PM
Administrator
 
Join Date: May 2007
Posts: 248
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
Using String or float on Numeric Fields in Salesrforce with PHP

I was working on this script over the past few days and in my orginal tutorial none of the fields that I supplied used or discussed any NUMERIC fields. I added two numeric fields to test the extraction process and I could not get the local array that I had created to be populated with the data coming in from the object from salesforce. This is just related to developers that are working with MySQL!

My orginal tutorial, Salesforce – PHP To MySQL Database Replication Script, did not have any numeric fields to work with, therefore I did not take this into consideration. For that I am sorry. So in order to work with numeric fields, such as currency, from salesforce.com, here is what worked for me:

Orginal Code:
PHP Code:
$pass_this['numeric_field1__c'] = $r->fields->numeric_field1__c;
$pass_this['numeric_field2__c'] = $r->fields->numeric_field2__c
the array > $pass_this was not being populated from the $r->fields object and it really threw me for a loop. I could not figure out why the fields were not being passed and it really started to get on my nerve. Then I remember that sometimes you have to tell PHP to cast variables to treat them a specific way. Look at my new php snippet:

PHP Code:
$pass_this['numeric_field1__c'] = (string)$r->fields->numeric_field1__c;
$pass_this['numeric_field2__c'] = (string)$r->fields->numeric_field2__c
By using the (string) function or cast, this makes PHP treat the object or variable as a string and then the value will pass to the array. You can also use (float) if you want to pass these values as a numeric field with decimals.

Here is a full example with a complete array being passed from $r to $pass_this (see attached)
Attached Files
File Type: txt php_string_example.txt (7.5 KB, 122 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



Powered by vBulletin


SEO by vBSEO 3.2.0 RC8 ©2008, Crawlability, Inc.

1 2 3 4 5