drupal 6中的drupal_write_record返回false

时间:2014-12-20 16:32:48

标签: php drupal drupal-6 drupal-modules

当我运行drupal_write_record时,它总是返回false。我调试了函数,看到在drupal_get_schema函数中找到的drupal_write_record函数返回false。此外,如果我调试drupal_get_schema函数并查看

 $schema = $cached->data; 

我的新表未包含在$schema数组中。我已经尝试刷新缓存,重新安装模块,并运行update.php但没有任何帮助。如果它有帮助,我还包括我写的.install文件,它将新表添加到数据库中:

<?php
// $Id: my_module.install,v 1.00.0.1 2012/10/21 00:23:32  Exp $

/**
 * Implementation of hook_schema().
 */
function my_module_schema() {
      $schema = array();
      $schema['my_module_pending_inserts'] = array(
        'fields' => array(
          'id' => array(
             'description' => 'primary key',
             'type' => 'serial',
             'size' => 'tiny',
             'not null' => TRUE,
          ),
          'json_array_data' => array(
            'type' => 'text',
            'not null' => TRUE,
          ),
          'successfully_run' => array(                
            'type' => 'int',
            'not null' => TRUE,
            'default' => 0,
          ),
          'date_created' => array(               
            'type' => 'int',
            'not null' => TRUE,
            'default' => 0,
          ),
          'date_updated' => array(               
            'type' => 'int',
            'not null' => TRUE,
            'default' => 0,
          )

        ),
        'primary key' => array('id'),
      );
    return $schema;
}

function jira_reporting_install() {
  // Create tables.
  drupal_install_schema('my_module_pending_inserts');
}

function my_module_uninstall() {
  // Remove tables.
  drupal_uninstall_schema('my_module_pending_inserts');

  // Delete variables
  variable_del('my_module_variable1');
  variable_del('my_module_variable2');
  variable_del('my_module_variable3');   

}

function my_module_update_2() {
    $up = array();
    $tbl = array(
            'fields' => array(
                'id' => array(
                    'type' => 'serial', 'not null' => TRUE
                ),
                'json_array_data' => array(
                    'type' => 'varchar',
                    'length' => 250,
                    'not null' => True
                ),
                'successfully_run' => array(
                       'type' => 'int'
                ),
                'date_created' => array(
                        'type' => 'int'
                ),
                'date_updated' => array(
                        'type' => 'int'
                ),
            ),
            'primary key' => array('id'),
        );


    db_create_table(&$up, 'my_module_pending_inserts', $tbl);
    return $up;
}

1 个答案:

答案 0 :(得分:0)

没关系,这是我的_schema名称中的拼写错误