Insert a record in DB
Hi all,
I try to insert a simple record into the Drupal's DB main schema but it does not work.
The code I post here is very simple. When the submit button is pressed, I want the record to be inserted.
function formexample_nameform_submit($form_id, $form_state) {
$table = 'Billet';
$record = new stdClass();
$record->id = 5
$record->description = t('new_try');
drupal_write_record($table, $record);
drupal_set_message(t('done'));
}
Furthermore, field type mapping has been done during the new module's installation.
function moduleName_Billet_schema() {
$schema['Billet'] = array(
'description' => t('description'),
'fields' => array(
'id' => array(
'description' => t('id'),
'type' => 'serial',
'not null' => TRUE,
),
'timeBillet' => array(
'description' => t('time'),
'type' => 'datetime',
'not null' => FALSE,
),
'description' => array(
'description' => t('descriptions'),
'type' => 'varchar',
'length' => '200',
'not null' => FALSE,
),
),
'primary key' => array('id'),
);
return $schema;
}
The Drupal user has the required privileges.
Can you tell me what could be wrong with that ?
Thanks !
- Login to post comments