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.

ParameterTypeDetails
datatype STRING Pod Name
tbl_row_id INT Pod Item ID (optional, if not provided save_pod_item will INSERT instead of UPDATE) - you can get this with $Record->get_field('id')
pod_id INT Pod ID (optional, if not provided save_pod_item will INSERT instead of UPDATE) - you can get this with $Record->get_pod_id()
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));

// sanitize the data (to keep your code database-safe)
$params = pods_sanitize($params);

// create the item
$person_id = $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 (tbl_row_id based)
$params = array('datatype' => 'person', 'tbl_row_id' => 2, 'columns' => array('name' => 'Rick', 'favorite_color' => 'Blue', 'gender' => 1));

// sanitize the data (to keep your code database-safe)
$params = pods_sanitize($params);

// save the item
$api->save_pod_item($params);

// all of the values to save and options to use (pod_id based)
$params = array('datatype' => 'person', 'pod_id' => 4, 'columns' => array('name' => 'Rick', 'favorite_color' => 'Blue', 'gender' => 1));

// sanitize the data (to keep your code database-safe)
$params = pods_sanitize($params);

// save the item
$api->save_pod_item($params);