【发布时间】:2018-07-25 07:49:24
【问题描述】:
我正在尝试在 .install 模块中创建一个新表,这就是我所做的:
$schema['commission_summary'] = array (
'description' => 'Récapitulatif des commissions',
'fields' => array(
'commission_summary_id' => array(
'description' => 'ID de commission',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'product_id' => array(
'description' => 'ID du produit lié',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'date_depart' => array(
'description' => 'Date du debut du voyage',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'prestataire' => array(
'description' => 'ID du partenaire lié (Agence)',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'nb_participant_total' => array(
'description' => 'Nombre de participants total',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'nb_participant_agence' => array(
'description' => 'Nombre de participants de l\'agence ',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('commission_summary_id'),
'indexes' => array(
'product_id' => array('product_id'),
'partner_id' => array('prestataire')
),
);
return $schema;
和
function ga_commission_update_7101() {
$table = 'commission_summary';
$schema = drupal_get_schema_unprocessed('commission_summary', $table);
db_create_table('commission_summary', $schema);
}
问题是我得到一个错误但我不知道为什么,我的语法看起来不错?
我创建了其他类似的表,所以我不明白为什么这次它不起作用
这是我得到的错误:
Failed: PDOException : SQLSTATE[42000]: Syntax error or access violation:
1064 You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use
near ') ENGINE = InnoDB DEFAULT CHARACTER SET utf8' at line 1: CREATE
TABLE {commission_summary} ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8;
Array ( ) dans db_create_table() (ligne 2776 dans
/var/www/clients/client1/web84/web/includes/database/database.inc).
【问题讨论】: