Attaching image files to nodes programmatically in Drupal 7
嗨,当我累积这个艺术品时,却遇到了一个pdo错误:
PDOException:SQLSTATE [23000]:完整性约束违规:1048 列'field_pr_quotation_file_display'不能为null:INSERT INTO {field_data_field_pr_quotation_file}(entity_type,entity_id, revision_id,bundle,delta,language,field_pr_quotation_file_fid, field_pr_quotation_file_display,field_pr_quotation_file_description) VALUES(:db_insert_placeholder_0,:db_insert_placeholder_1, :db_insert_placeholder_2,:db_insert_placeholder_3, :db_insert_placeholder_4,:db_insert_placeholder_5, :db_insert_placeholder_6,:db_insert_placeholder_7, :db_insert_placeholder_8);数组([:db_insert_placeholder_0] =>节点 [:db_insert_placeholder_1] => 136 [:db_insert_placeholder_2] => 249 [:db_insert_placeholder_3] =>采购申请 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => UND [:db_insert_placeholder_6] => 24 [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => )in field_sql_storage_field_storage_write()(第451行) d:\ WWW \网站\ PR \模块\字段\模块\ field_sql_storage \ field_sql_storage.module)
答案 0 :(得分:0)
https://drupal.stackexchange.com/questions/69684/how-to-assign-value-from-one-file-field-to-another-programmatically根据这里,我添加display = 1
$field_file = (array) $file;
$field_file['display'] = 1;
dpm($file,'field_pr_ref_quotation_file');
$node->field_pr_ref_quotation_file[LANGUAGE_NONE][] = $field_file;