文件字段以编程方式显示drupal 7中的PDOException

时间:2013-06-13 15:01:05

标签: php file pdo field

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)

1 个答案:

答案 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;