Icon edb_jsonccommit

Commits an Elevate Web Builder transaction using JSON transaction data.

Syntax
edb_jsoncommit(<ConnectionHandle>, <DataSetTables>,
                       <TransactionJSON>, [<LocalizeDateTimeColumns>])

<ConnectionHandle> =

Handle of connection returned by edb_connect function

<DataSetTables> =

Associative array of dataset names and base table names

<TransactionJSON> =

String containing JSON transaction data

<LocalizeDateTimeColumns> =

Boolean indicating whether to convert date/time columns to local time

Returns
TRUE if successful, or FALSE if there are any errors

Usage
The edb_jsoncommit function is used to consume JSON transactions from an Elevate Web Builder application. The DataSetTables parameter is an associative array of dataset names and their associated base table names. This information is used to determine which base tables should be updated during the transaction commit. If any datasets in the incoming JSON are not specified in the DataSetTables associative array, then an error will result.

The LocalizeDateTimeColumns parameter indicates whether date/time columns should be converted from UTC time to local time before being stored in the database. The default value for this parameter is False.

Please see the Elevate Web Builder manual for more information on datasets and the JSON data formats used with them.

Examples
<?php

// The following script connects to an ElevateDB
// Server and database, and commits an Elevate
// Web Builder JSON transaction on
// the Customer and Orders tables using the
// edb_jsoncommit() function, and then
// disconnects using the edb_disconnect() function

$con = edb_connect("type=remote;charset=Ansi;address=127.0.0.1;"+
                   "uid=Administrator;pwd=EDBDefault;database=Test");
if (!$con)
  {
  die("Could not connect: " . edb_errmsg());
  }

if ($_GET["method"])
   {
   switch ($_GET["method"])
      {
      case "commit":
         if (!edb_jsoncommit($con, array("Customer" => "customer",
                                         "Orders" => "orders"),
                                         $HTTP_RAW_POST_DATA))
            {
            die("Error committing database transaction (" . edb_errmsg() . ")";
            }
         break;
      }
  }
else
  {
  die("Database method not specified";
  }

edb_disconnect($con);
?>
Image