Zem: Блог

Главные вкладки

Создать таблицу в БД.

21 января 2011 в 16:39

Пишу модуль по созданию каталога книг. Создаю таблицу в БД элементарную, однако почему то не создается.
Прилагаю код .install. Сведущие люди подскажите в чем загвоздка Smile

function bookform_schema() {
    $schema['bookform'] = array(
        'description' => 'DB for books.',
        'fields' => array(
            'BookName' => array(
                'description' => '',
                'type' => 'text',
                'size' => 'small',
                'length' => 32,
                'not null' => TRUE,
                'default' => ''),

            'AuthorName' => array(
                'description' => '',
                'type' => 'text',
                'size' => 'small',
                'length' => 32,
                'not null' => TRUE,
                'default' => ''),

            'Description' => array(
                'description' => '',
                'type' => 'text',
                'size' => 'medium',
                'length' => 32,
                'not null' => TRUE,
                'default' => ''),

            'indexes' => array(
                'bookfrom_BookName' => 'BookName',
                'bookfrom_BookName' => 'AuthorName',
                'bookfrom_BookName' => 'Description',),
            ),
            'primary key' => array('BookName'),
        );
    return $schema;
}

function bookform_install() {
    drupal_install_schema('bookform');
}

function bookform_uninstall() {
    drupal_uninstall_schema('bookform');
}

Создать таблицу в БД.

21 января 2011 в 16:38

Пишу модуль по созданию каталога книг. Создаю таблицу в БД элементарную, однако почему то не создается.
Прилагаю код .install. Сведущие люди подскажите в чем загвоздка Smile

function bookform_schema() {
    $schema['bookform'] = array(
        'description' => 'DB for books.',
        'fields' => array(
            'BookName' => array(
                'description' => '',
                'type' => 'text',
                'size' => 'small',
                'length' => 32,
                'not null' => TRUE,
                'default' => ''),

            'AuthorName' => array(
                'description' => '',
                'type' => 'text',
                'size' => 'small',
                'length' => 32,
                'not null' => TRUE,
                'default' => ''),

            'Description' => array(
                'description' => '',
                'type' => 'text',
                'size' => 'medium',
                'length' => 32,
                'not null' => TRUE,
                'default' => ''),

            'indexes' => array(
                'bookfrom_BookName' => 'BookName',
                'bookfrom_BookName' => 'AuthorName',
                'bookfrom_BookName' => 'Description',),
            ),
            'primary key' => array('BookName'),
        );
        var_dump ($schema);
        exit;
    return $schema;
}

function bookform_install() {
        var_dump ($schema);
        exit;
    drupal_install_schema('bookform');
}

function bookform_uninstall() {