Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drupal 7 .install文件未在drupal中创建表_Drupal 7 - Fatal编程技术网

Drupal 7 .install文件未在drupal中创建表

Drupal 7 .install文件未在drupal中创建表,drupal-7,Drupal 7,嗨,我是drupal的新手。我只是创建了一个模块,用一些输入创建一个表单。我为同一个文件编写了.install文件,但它并没有创建表。当我安装此模块时,它既不显示错误也不显示安装表 function mycontact_schema() { $schema['mycontact'] = array( 'description' => t('This table for mycontact.'), 'fields' => array(

嗨,我是drupal的新手。我只是创建了一个模块,用一些输入创建一个表单。我为同一个文件编写了.install文件,但它并没有创建表。当我安装此模块时,它既不显示错误也不显示安装表

function mycontact_schema() {
     $schema['mycontact'] = array(
        'description' => t('This table for mycontact.'),
        'fields' => array(
          'mycontctid' => array(
            'description' => t('The primary identifier for a mycontact.'),
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE),
          'vid' => array(
            'description' => t('The current {mycontact_revisions}.vid version identifier.'),
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0),
          'name' => array(
            'description' => t('The {mycontact_name} of this mycontact.'),
            'type' => 'varchar',
            'length' => 32,
            'not null' => TRUE,
            'default' => ''),
          'email' => array(
            'description' => t('The name of this contact, always treated a non-markup plain text.'),
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => ''),
          ),
          'comments' => array(
            'description' => t('The comments of this contact, always treated a non-markup plain text.'),
            'type' => 'text',
            'not null' => TRUE,
            'default' => ''),
        'primary key' => array('mycontctid'),
        );
        return $schema;
    }
It is not showing any error and any warning. 

hook_安装实现中没有任何错误。
我遵循以下步骤使其工作:

  • sites/all/modules
    内创建了名为
    mycontact
    的目录
  • 在文件
    mycontact.info
    mycontact.module
    mycontact.install
    中创建了一个文件
  • mycontact.info
    中,我添加了以下行:

    name = my contact
    core = 7.x
    
  • mycontact.install
    文件中,我复制了问题中的所有代码
  • mycontact.module
    文件留空。注意:Drupal需要这个空文件
  • 已启用该模块。成功了
    您现在可以做的是,禁用模块->卸载它->按照上述步骤安装模块;您应该为自己创建数据库表。

    如何卸载它?只是禁用它?请尝试“卸载”它。为什么我需要保留空的.module文件。我创建的mycontact.info文件将信息放在了这里。已创建mycontact.module文件并启用它。检查我的表格,一切正常。在创建.install文件并禁用模块并再次启用之后,表单看起来很好,但并没有在数据库中创建表。@innovativeKundan不需要将文件保持为空。我只是想强调drupal需要这个文件。
    hook\u模式
    只在模块安装时启动,而不是每次启用时启动。要创建表,应在禁用模块后卸载该模块。然后再次激活它来触发钩子。是的。。thanx@Ajit实际上我也这么做了,而且效果很好。我卸载模块并重新安装。谢谢。喜欢吗