0

Hello All,

I know how to fetch record with the help of podscms, But I would like to update the record fetched by podscms. like

$somePod = pods('somepod')->update($my_array);

Anybody have some suggestion,

Farhan
  • 13
  • 5

1 Answers1

1

This is available in pods()->save() - http://pods.io/docs/save/

<?php
// Get the book item with an ID of 5
$pod = pods( 'book', 5 );

// Set the author (a user relationship field)
// to a user with an ID of 2
$pod->save( 'author', 2 );

// Set a group of fields to specific values
$data = array(
    'name' => 'New book name',
    'author' => 2,
    'description' => 'Awesome book, read worthy!'
);

// Save the data as set above
$pod->save( $data );

// Or the shorthand
$id = pods( 'yourpod', $id )->save( $data );

Also available is add() - http://pods.io/docs/add/

  • How do you save a multiple relationship? like for eg two "authors"? $pod->save( 'author', array(1,2) ) doesn't work. – Bakaburg Jun 16 '13 at 20:13
  • As long as author is a multiple select limited to 2+ (or no limit), passing an array should work. We also support '1,2' comma separated values. – Scott Kingsley Clark Jul 01 '13 at 00:15