0

在 Drupal 7 自定义模块中,我正在使用表单更新数据库中的记录,并且我正在使用以下代码进行更新,但由于某种原因它没有更新,谁能告诉我为什么?我尝试了 3 个小时来改变所有可能的事情,但没有运气

函数 edit_job_form_submit($form, &$form_state){

    $id = $form_state['values']['id'];
    $job_title = $form_state['values']['job_title'];
    $description = $form_state['values']['description'];
    $cat_id = $form_state['values']['cat_id'];
    $job_type = $form_state['values']['job_type'];
    $company_id = $form_state['values']['company_id'];
    $description = $form_state['values']['description'];
    $location = $form_state['values']['location'];
    $Salary = $form_state['values']['Salary'];
    $benifits = $form_state['values']['benifits'];
    $Nationality = $form_state['values']['Nationality'];
    $Age = $form_state['values']['Age'];
    $join_date = $form_state['values']['join_date'];
    $date_added = date("y-m-d", time());
    $join_date_mod = gmdate('Y-m-d',strtotime($join_date));

    $num_updated  = db_update('echelon_jobs')
    ->fields(array(
    'job_title' => $job_title,
     'cat_id' => $cat_id,
    'job_type' => $job_type,
    'company_id' => $company_id,
    'location' => $location,
    'Salary' => $Salary,
    'benifits' => $benifits,
    'Nationality' => $Nationality,
    'Age' => $Age,
    'join_date' => $join_date_mod,
    'date_added' => $date_added,
       ))
    ->condition('id', $id)
    ->execute();

   //dpq($num_updated, $name);
    drupal_set_message(t('Vacancy Updated Successfully..  '));

}

4

2 回答 2

2

可能是你条件不对。可能是您的变量 id 具有空值或表中不存在的某个值。

于 2013-10-04T10:14:40.863 回答
1
  1. 检查 db_update() 返回什么
  2. 在 drupal/mysql 日志中打开错误报告并检查是否有任何错误
于 2013-10-06T11:31:05.260 回答