Title: Insert with additional field
Last modified: March 22, 2022

---

# Insert with additional field

 *  Resolved [jaceejoef](https://wordpress.org/support/users/jaceejoef/)
 * (@jaceejoef)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/insert-with-additional-field/)
 * Hi,
 * I use pandarf_insert function to insert content and it does its job but only 
   if I insert just the name field. I have two fields: name and image.
 * This code works:
 *     ```
       $id_int = pandarf_insert(
       	array( 
       		'name' => '11112'
       	), 
       	array( 
       		'child_pod_name' => 'fabric_code', 
       		'parent_pod_id' => 548, // parent cpt id
       		'parent_pod_post_id' => 1201, // the post id
       		'parent_pod_field_id' => 566, // parent cpt field id
       		'user_id' => 1
       	), 
       	true
       );
       ```
   
 * This code doesn’t work:
 *     ```
       $id_int = pandarf_insert(
       	array( 
       		'name' => '11112',
       		'image' => '1138' // also tried image link here but does nothing
       	), 
       	array( 
       		'child_pod_name' => 'fabric_code', 
       		'parent_pod_id' => 548, // parent cpt id
       		'parent_pod_post_id' => 1201, // the post id
       		'parent_pod_field_id' => 566, // parent cpt field id
       		'user_id' => 1
       	), 
       	true
       );
       ```
   
 * The non-working code returns this SQL:
    `INSERT INTO 'wp_osnnwxgsg5_pods_fabric_code'('
   name','image','pandarf_parent_pod_id','pandarf_parent_post_id','pandarf_pod_field_id','
   pandarf_created','pandarf_modified','pandarf_modified_author','pandarf_author','
   pandarf_order' ) VALUES ( 11112,1138,548,1201,566,'2022-03-22 23:18:50','2022-
   03-22 23:18:50',1,1,3 );` I execute this SQL and it says “image” is an unknown
   column.
 * To investigate further, I insert the content in the dashboard instead of code
   and checked how they are placed in the database tables. The content with the 
   name field is added in the wp_osnnwxgsg5_pods_fabric_code table and the image
   field is added on wp_osnnwxgsg5_podsrel.
 * These are the screenshots of the database tables:
 * > [View post on imgur.com](https://imgur.com/lZEosVJ)
 * > [View post on imgur.com](https://imgur.com/4npBO45)
    -  This topic was modified 4 years, 2 months ago by [jaceejoef](https://wordpress.org/support/users/jaceejoef/).
      Reason: formatting
    -  This topic was modified 4 years, 2 months ago by [jaceejoef](https://wordpress.org/support/users/jaceejoef/).
      Reason: additional info
    -  This topic was modified 4 years, 2 months ago by [James Huff](https://wordpress.org/support/users/macmanx/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Coding Panda](https://wordpress.org/support/users/codingpanda/)
 * (@codingpanda)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/insert-with-additional-field/#post-15487467)
 * Hi [@jaceejoef](https://wordpress.org/support/users/jaceejoef/)
 * When I created that function, I was not aware that it didn’t work for files.
 * pandarf_insert returns the id when the insert is successful, so the workaround
   is to use Pods save API: [https://docs.pods.io/code/pods/save/](https://docs.pods.io/code/pods/save/)
 *     ```
       $id_int = pandarf_insert(
       	array( 
       		'name' => '11112'
       	), 
       	array( 
       		'child_pod_name' => 'fabric_code', 
       		'parent_pod_id' => 548, // parent cpt id
       		'parent_pod_post_id' => 1201, // the post id
       		'parent_pod_field_id' => 566, // parent cpt field id
       		'user_id' => 1
       	), 
       	true
       );
       $pod = pods( 'fabric_code', $id_int );
       $data = array(
               'image' => array(
                   'id'    => 1138,   
               )
       );
       $pod->save( $data );
       ```
   
 * Let me know if that works.
    -  This reply was modified 4 years, 2 months ago by [Coding Panda](https://wordpress.org/support/users/codingpanda/).
 *  Thread Starter [jaceejoef](https://wordpress.org/support/users/jaceejoef/)
 * (@jaceejoef)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/insert-with-additional-field/#post-15498224)
 * Hi [@codingpanda](https://wordpress.org/support/users/codingpanda/)
 * Thank you for the workaround code. It works!
 * I was able to make it work using an SQL code but your code is neater so I’ll 
   use that.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Insert with additional field’ is closed to new replies.

 * ![](https://ps.w.org/panda-pods-repeater-field/assets/icon-128x128.png?rev=1520380)
 * [Panda Pods Repeater Field](https://wordpress.org/plugins/panda-pods-repeater-field/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/panda-pods-repeater-field/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/panda-pods-repeater-field/)
 * [Active Topics](https://wordpress.org/support/plugin/panda-pods-repeater-field/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/panda-pods-repeater-field/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/panda-pods-repeater-field/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [jaceejoef](https://wordpress.org/support/users/jaceejoef/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/insert-with-additional-field/#post-15498224)
 * Status: resolved