save_pod_item
(Since 1.7.9) -- add or edit a pod item
function save_pod_item($params)
Parameters
The following options are contained within the $params variable as an ARRAY.
| Parameter | Type | Details |
|---|---|---|
| datatype | STRING | Pod Name |
| pod_id | INT | Pod ID (optional, if not provided save_pod_item will INSERT instead of UPDATE) |
| columns | ARRAY | An associative of the column names and values (see examples) |
Security and Data Sanitization
We strongly recommend running all of your data through our pods_sanitize function before saving. Otherwise, your data could cause errors in the saving process and make your code insecure.
$data = pods_sanitize($data);
PICK and FILE column values
These column types should save the related ID. For multiple IDs, separate by comma.
Examples
This code will add a new item to the 'person' Pod.
// gender is a PICK column, the value must be the ID(s) of the related item(s),
// separate multiple by comma (if column has 'multiple' option checked)
// in this case, 1 = Male and 2 = Female
// initialize the api
$api = new PodAPI();
// all of the values to save and options to use
$params = array('datatype' => 'person', 'columns' => array('name' => 'Rick', 'favorite_color' => 'Blue', 'gender' => 1));
// create the item
$api->save_pod_item($params);
This code will edit an item in the 'person' Pod.
// initialize the api
$api = new PodAPI();
// all of the values to save and options to use
$params = array('datatype' => 'person', 'pod_id' => 4, 'columns' => array('name' => 'Rick', 'favorite_color' => 'Blue', 'gender' => 1));
// save the item
$api->save_pod_item($params);
