You are here

class sObject in Salesforce Suite 5

Same name and namespace in other branches
  1. 5.2 includes/salesforce.php \sObject

salesforce sObject.

@access public

Hierarchy

Expanded class hierarchy of sObject

2 string references to 'sObject'
soap_parser::end_element in includes/nusoap.php
* end-element handler * *
sObject::serialize in includes/salesforce.php

File

includes/salesforce.php, line 403

View source
class sObject {
  var $type;
  var $id;
  var $values;
  var $fieldsToNull;
  function sObject($type, $id = null, $values = null, $fieldsToNull = null) {

    // deserialize record from nusoap.php
    if (is_array($type)) {
      $this->values = array();
      foreach ($type as $k => $v) {
        if ($k == 'type') {
          $this->type = $v;
        }
        else {
          if ($k == 'Id') {
            if (is_array($v)) {
              $this->id = $v[0];
            }
            else {
              $this->id = $v;
            }
          }
          else {
            $this->values[$k] = $v;
          }
        }
      }
    }
    else {
      $this->type = $type;
      $this->id = $id;
      $this->values = $values;
      $this->fieldsToNull = $fieldsToNull;
    }
  }
  function serialize() {
    $valuesSer['type'] = $this->type;
    if ($this->fieldsToNull != null) {
      $fieldsToNull = array();
      $index = 0;
      foreach ($this->fieldsToNull as $value) {
        $fieldsToNull[$index] = $value;
        $index++;
      }
      $valuesSer['fieldsToNull'] = new RepeatedElementsArray('fieldsToNull', $fieldsToNull);
    }
    $valuesSer['Id'] = $this->id;
    foreach ($this->values as $k => $v) {
      $valuesSer[$k] = $v;
    }
    $sobj = new soapval('sObject', false, $valuesSer);
    return $sobj
      ->serialize();
  }

}

Members