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:
- The topic ‘Insert with additional field’ is closed to new replies.