簡體   English   中英

drupal 7模塊不會向Mysql插入任何內容

[英]drupal 7 module wont insert anything to Mysql

今天,我在為我的自定義模塊苦苦掙扎。 現在的問題是,當我調用頁面回調(其中有db_insert查詢)時,它將返回我internall 500(顯示消息:sql state 4200,查詢有問題)。 因此javascript調用該頁面巫婆將啟動模塊,並且在進一步開發中它將提供參數,就像它將插入MySQL一樣。 這是da hook:

array_push($values, array(
    'who' => 'a',
    'when' => 'a',
    'where' => 'a',
     )
);
$testi = array(
    'who' => 'me', 
    'when' => 'yesterday', 
    'where' => 'yomama',
    );
$query = db_insert('tablename')
    ->fields( $testi )
    ->execute();

print_r($testi);

我一直在測試查詢的所有“格式”。 例如:

$query = db_insert('pgstats')
    ->fields( array(
    'who' => 'me', 
    'when' => 'yesterday', 
    'where' => 'yomama',
    ))
    ->execute();

但是什么都沒有

編輯:@ 2pha建議提供此信息:

PDOException:SQLSTATE [42000]:語法錯誤或訪問沖突:1064 SQL語法錯誤; 在第1行:INSERT INTO {pgstats}(誰,何時, ,其中)VALUES(:db_insert_placeholder_0,:db_insert_placeholder_1,:db_insert_placeholder_2); stats_recieve_info()中的數組([:db_insert_placeholder_0] =>我[:db_insert_placeholder_1] =>昨天[:db_insert_placeholder_2] => yomama)(模塊文件的第53行)

我找到了它不起作用的原因! 我的表有稱為“ where”和“ when”的列,由於某種原因,drupal並沒有將它們作為列名傳遞,而是作為語法。 那些日子中的一天....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM