function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chris38chris38 

PHP5 - update some records

I want to select some records in a table and then modify them.
The execution failed when i try to update(Id not specified).
I don't really understand how to specify TheId for updating.
Thanks for help !

Hereafter my code :
// select some records
$query = "select * from contact where LastName like 'R%'";
$queryOptions = new QueryOptions(300);
$queryResponse = $this->mySforceConnection->query($query, $queryOptions);
$this->assertNotNull($queryResponse);
// update the field FirstName to 'Barbara'
$updateFields = array ("ID" => $this->theId, "FirstName" => 'Barbara');
$updateResponse = $this->mySforceConnection->update('Contact', $updateFields);

chris
Tran ManTran Man
Get the latest PHP5 toolkit from http://sourceforge.net/project/showfiles.php?group_id=96634&package_id=183732

The new way to update is by using SObjects:


      $updateFields = array (
        'Id' => $id,
        'MailingCity' => 'New York',
        'MailingState' => 'NY'
      );
      $sObject1 = new SObject();
      $sObject1->fields = $updateFields;
      $sObject1->type = 'Contact';
      $updateResponse = $this->mySforceConnection->update(array ($sObject1));
chris38chris38
Hi,

Thanks for the sample.
The only thing that I can't understand is where the $id comes from.

I saw the toolkit samples. I saw how it works when a record is created, but not how to modify an existing record.
It seems that I can't call a SQL query using 'update'.Is it right ?

What is $id ? The value of a key data, or other thing ?

The process that I have to do is :
- select a record by a key value (ok, I know to do it)
- then update some fields in this record (how to refer to the selected record ?)

An other thing : It seems that i can't write a query like 'select * from Contact'. Shall i give the explicit list of used fields ?

I hope you can help me
Thanks
Tran ManTran Man
Sure.

$id was defined elsewhere in my code which I didn't include.  It represents the id of the Contact object.  "Update" is done in the edit.php of the sample.

Our query language is SOQL.  Read more about in our docs under API Calls/Sforce Object Query Language (SOQL).  You need to explicitly name the fields you want to retrieve.

HTH

chris38 wrote:
Hi,

Thanks for the sample.
The only thing that I can't understand is where the $id comes from.

I saw the toolkit samples. I saw how it works when a record is created, but not how to modify an existing record.
It seems that I can't call a SQL query using 'update'.Is it right ?

What is $id ? The value of a key data, or other thing ?

The process that I have to do is :
- select a record by a key value (ok, I know to do it)
- then update some fields in this record (how to refer to the selected record ?)

An other thing : It seems that i can't write a query like 'select * from Contact'. Shall i give the explicit list of used fields ?

I hope you can help me
Thanks


Message Edited by Tran Man on 04-19-2006 10:28 AM

Tran ManTran Man
Btw,

Be sure to check out the AppExchange Explorer or the Eclipse plugin.  Both give you the capability to browse your database schema and data which can be incredibly helpful.

Message Edited by Tran Man on 04-26-2006 04:30 PM