Adding & Deleting Entities (Records)

Intro #

TrackZero uses what is known as Upsert (Update or Insert). Creating an Entity or updating it uses the same operation. This allows undeterministic creation of Entities (Or updating), which means you don’t have to remember the state of an Entity in order to determine whether you need to update or create.

Upsert an Entity #

					$analytics_space_id = "Merchant8";
$entity = new Entity("Order",7382);
$entity->add_attribute("total value", 990)
       ->add_attribute("time", new \DateTime())
       ->add_entity_reference_attribute("Items", "Product", 1)
       ->add_entity_reference_attribute("Items", "Product", 6)
       ->add_entity_reference_attribute("Ship To", "Address", "888999123");
$trackZero_Client->upsert_entity($analytics_space_id, $entity);


Delete an Entity #

					$trackZeroClient->delete_entity($analytics_space_id, "Order", 7382);