Drupal 7更新查询无效

时间:2013-10-03 10:02:19

标签: drupal drupal-7

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

function 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..  '));

}

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

  1. 检查db_update()返回的内容
  2. 打开drupal / mysql日志记录中的错误报告并检查是否有错误