2013-07-01 118 views
0
$table_name = 'tbl_users'; 
$data = array('datetime'=>'NOW()', 
       'ipadress' => $ipaddress, 
       'name' => $name, 
       'dob' => $dob, 
       'nationality' => $nationality, 
       'address' => $address, 
       'city' => $city, 
       'state' => $state, 
       'pincode' => $pincode, 
       'phone' => $phone, 
       'email' => $email, 
       'mobile' => $mobile, 
       'weight' => $weight, 
       'height'=> $height, 
       'marital' => $marital, 
       'degree' => $degree, 
       'institute' => $institute, 
       'special' => $special, 
       'yearofpaas' => $yearofpaas, 
       'grade' => $grade, 
       'emplyment_history' => $emplyment_history, 
       'merits' => $merits, 
       'major_achivements' => $major_achivements, 
       'interview_attended' => $interview_attended, 
       'details' => $details, 
       'minctc_position' => $minctc_position, 
       'cv_file' => $cv_file, 
       'declaration' => $declaration); 
echo "<pre>"; 
print_r($data); 
drupal_write_record($table_name, $data); 

我有這樣的插入查詢,但不知何故記錄不給任何人table..can要在請幫我...什麼在查詢中的問題?????插入查詢在Drupal 7

+0

的問題可能會是' '日期時間'=> 'NOW()''線。 Drupal將(正確)將其作爲參數轉義,並且'datetime'字段將驗證失敗。看看http://drupal.stackexchange.com/questions/35465/how-to-set-a-datetime-field-now-during-insert – Clive

回答

1

你在NOW()中傳遞一個字符串,這是行不通的。嘗試改爲:

$data = array('timestamp' => date("Y-m-d H:i:s"), 
0

DBLOG可以給你關於你的查詢問題的好主意。路徑爲admin/reports/dblog

1

drupal_write_record只有當表架構中存在my_module.install文件工作。

here:drupal_write_record保存(插入或更新)記錄到基於模式數據庫

因此,確保tbl_users表的模式存在。 另外,如Dan U.所述,使用date("Y-m-d H:i:s")而不是'Now()'