DrupalBin
Submit Code
About
Recent Posts
Code
Fix for Fix for Code
Fix for Code
Code
Node type whitelist
an axe coach accessories
coach purses married
Fix for de las ghd alturas
de las ghd alturas
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
Fix for Is this the right way to schema
View
Fix
May 17, 2010 - 3:53pm — Anonymous
<?php
/**
* Implementation of hook_install().
*/
function
another_form_install
(
)
{
drupal_install_schema
(
'another_form'
)
;
}
/**
* Implementation of hook_uninstall().
* Comment it out in production, there is no reason delete the tables that store the values
*/
function
another_form_uninstall
(
)
{
drupal_uninstall_schema
(
'another_form'
)
;
}
/**
* Implementation of hook_schema().
*/
function
another_form_schema
(
)
{
$schema
=
array
(
)
;
$schema
[
'another_form_sflead'
]
=
array
(
'description'
=
>
t
(
'Lead Submissions'
)
,
'fields'
=
>
array
(
'sid'
=
>
array
(
'description'
=
>
t
(
'The unique identifier for this submission.'
)
,
'type'
=
>
'serial'
,
'unsigned'
=
>
TRUE
,
'not null'
=
>
TRUE
,
)
,
'time'
=
>
array
(
'description'
=
>
t
(
'Timestamp of when the form was submitted.'
)
,
'type'
=
>
'int'
,
'unsigned'
=
>
TRUE
,
'not null'
=
>
TRUE
,
)
,
'firstname'
=
>
array
(
'description'
=
>
'FirstName'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'lastname'
=
>
array
(
'description'
=
>
'LastName'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'phone'
=
>
array
(
'description'
=
>
'Phone'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'email'
=
>
array
(
'description'
=
>
'Email'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'newsletter'
=
>
array
(
'description'
=
>
'Newsletter'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'event'
=
>
array
(
'description'
=
>
'Event'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'attendees'
=
>
array
(
'description'
=
>
'Attendees'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'post'
=
>
array
(
'description'
=
>
'The Actual Post'
,
'type'
=
>
'text'
,
)
,
)
,
'unique keys'
=
>
array
(
'sid'
=
>
array
(
'sid'
)
)
,
'primary key'
=
>
array
(
'sid'
)
,
)
;
$schema
[
'another_form_sfcontact'
]
=
array
(
'description'
=
>
'Service Form Submissions.'
,
'fields'
=
>
array
(
'sid'
=
>
array
(
'description'
=
>
'The unique identifier for this submission.'
,
'type'
=
>
'serial'
,
'unsigned'
=
>
TRUE
,
'not null'
=
>
TRUE
,
)
,
'time'
=
>
array
(
'description'
=
>
'Timestamp of when the form was submitted.'
,
'type'
=
>
'int'
,
'unsigned'
=
>
TRUE
,
'not null'
=
>
TRUE
,
'default'
=
>
0
,
)
,
'firstname'
=
>
array
(
'description'
=
>
'First Name'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'lastname'
=
>
array
(
'description'
=
>
'Last Name'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'phone'
=
>
array
(
'description'
=
>
'Phone'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'email'
=
>
array
(
'description'
=
>
'Email'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'option'
=
>
array
(
'description'
=
>
'Options'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'content'
=
>
array
(
'description'
=
>
'Content'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'post'
=
>
array
(
'description'
=
>
'The Actual Post'
,
'type'
=
>
'text'
,
)
,
)
,
'unique keys'
=
>
array
(
'sid'
=
>
array
(
'sid'
)
)
,
'primary key'
=
>
array
(
'sid'
)
,
)
;
$schema
[
'another_form_sfemail'
]
=
array
(
'description'
=
>
'Stores all submitted field data for salesForm submissions.'
,
'fields'
=
>
array
(
'sid'
=
>
array
(
'description'
=
>
'The unique identifier for this submission.'
,
'type'
=
>
'serial'
,
'unsigned'
=
>
TRUE
,
'not null'
=
>
TRUE
,
)
,
'email'
=
>
array
(
'description'
=
>
'Email'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'time'
=
>
array
(
'description'
=
>
'Time Field'
,
'type'
=
>
'varchar'
,
'length'
=
>
255
,
)
,
'post'
=
>
array
(
'description'
=
>
'The Actual Post'
,
'type'
=
>
'text'
,
)
,
)
,
'unique keys'
=
>
array
(
'sid'
=
>
array
(
'sid'
)
)
,
'primary key'
=
>
array
(
'sid'
)
,
)
;
return
$schema
;
}
schema
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?php /** * Implementation of hook_install(). */ function another_form_install() { drupal_install_schema('another_form'); } /** * Implementation of hook_uninstall(). * Comment it out in production, there is no reason delete the tables that store the values */ function another_form_uninstall() { drupal_uninstall_schema('another_form'); } /** * Implementation of hook_schema(). */ function another_form_schema() { $schema = array(); $schema['another_form_sflead'] = array( 'description' => t('Lead Submissions'), 'fields' => array( 'sid' => array('description' => t('The unique identifier for this submission.'), 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'time' => array('description' => t('Timestamp of when the form was submitted.'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, ), 'firstname' => array('description' => 'FirstName', 'type' => 'varchar', 'length' => 255, ), 'lastname' => array('description' => 'LastName', 'type' => 'varchar', 'length' => 255, ), 'phone' => array('description' => 'Phone', 'type' => 'varchar', 'length' => 255, ), 'email' => array('description' => 'Email', 'type' => 'varchar', 'length' => 255, ), 'newsletter' => array('description' => 'Newsletter', 'type' => 'varchar','length' => 255,), 'event' => array('description' => 'Event', 'type' => 'varchar', 'length' => 255,), 'attendees' => array('description' => 'Attendees', 'type' => 'varchar', 'length' => 255,), 'post' => array('description' => 'The Actual Post', 'type' => 'text', ), ), 'unique keys' => array('sid' => array('sid')), 'primary key' => array('sid'), ); $schema['another_form_sfcontact'] = array( 'description' => 'Service Form Submissions.', 'fields' => array( 'sid' => array('description' => 'The unique identifier for this submission.' , 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE,), 'time' => array('description' => 'Timestamp of when the form was submitted.' , 'type' => 'int' , 'unsigned' => TRUE,'not null' => TRUE,'default' => 0,), 'firstname' => array('description' => 'First Name', 'type' => 'varchar', 'length' => 255, ), 'lastname' => array('description' => 'Last Name', 'type' => 'varchar','length' => 255, ), 'phone' => array('description' => 'Phone','type' => 'varchar', 'length' => 255, ), 'email' => array('description' => 'Email', 'type' => 'varchar','length' => 255, ), 'option' => array('description' => 'Options', 'type' => 'varchar' ,'length' => 255,), 'content' => array('description' => 'Content','type' => 'varchar' , 'length' => 255, ), 'post' => array('description' => 'The Actual Post','type' => 'text',), ), 'unique keys' => array('sid' => array('sid')), 'primary key' => array('sid'), ); $schema['another_form_sfemail'] = array( 'description' => 'Stores all submitted field data for salesForm submissions.', 'fields' => array( 'sid' => array('description' => 'The unique identifier for this submission.', 'type' => 'serial', 'unsigned' => TRUE,'not null' => TRUE, ), 'email' => array('description' => 'Email', 'type' => 'varchar','length' => 255, ), 'time' => array('description' => 'Time Field','type' => 'varchar','length' => 255, ), 'post' => array('description' => 'The Actual Post','type' => 'text',), ), 'unique keys' => array('sid' => array('sid')), 'primary key' => array('sid'), ); return $schema; }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.