The Schema API allows modules to declare their database tables in a structured array (similar to the Form API). If your question is about the database API, and not the schema API, use "db-api."
1
vote
1answer
13 views
After adding a column to a module's schema, should the new column also be placed inside hook_schema?
I have my own module which implements its own schema. I now want to add a column to the table provided by the schema, which I plan on accomplishing via hook_update_N() and db_add_field().
My question ...
2
votes
1answer
94 views
How to implement a mysql date or datetime field correctly in hook_schema()?
I have written a mymodule.install file which contains a schema definition to create a table in my database. This table contains two data fields. Theese fields will be populated by the users when they ...
1
vote
1answer
56 views
While developing a custom module, which function creates table in database?
While developing a custom module in Drupal 7, which function actually creates tables in the database?
I have implemented hook_schema in mymodule.install, mymodule.info, mymodule.module file and ...
2
votes
1answer
123 views
array_keys() expects parameter 1 to be array, null given in drupal_schema_fields_sql()?
i have developed a custom module which will calculate the employee salary . I have created the hook_schema() like this
This is mymodule.install file with two entities
function payroll_schema() {
...
2
votes
3answers
64 views
how to add multiple tables in hook_schema() in .install file while creating custom module?
Is it possible to add multiple tables in hook_schema() while creating a custom module? I have created a custom module with the help of Drupal entities. Will it be possible to store two different table ...
0
votes
1answer
35 views
How can I use a custom table as a node type?
I am reasonably new to Drupal, I have written a couple of basic modules by following the excellent videos from buildamodule.com
Now I need to somehow integrate an existing table into a drupal site. ...
-3
votes
1answer
41 views
Propagate changes inside module.install schema to database
Using schema module, I was able to easily describe tables that I included in Drupal DB, by creating .install files to appropriate modules.
Now i have updated field descriptions for each field ...
0
votes
1answer
32 views
How to create a Hook_Schema for Fieldset Form?
i have a form i would like to have the values submitted into a table in mysql database using hook_schema in a .install file. problem is i have no idea how to properly write it out being new to php ...
1
vote
1answer
20 views
A table was not created by _schema() function
I added this function to cleanetica_advanced module and after this ran /update.php
function cleanetica_advanced_schema() {
$schema['videos'] = array (
'description' => 'Videos with HTML ...
1
vote
1answer
62 views
how to create db table with initial data from custom module [duplicate]
Possible Duplicate:
Adding content to a database table during module install
rewrite:
I've got a question about Db tables.
I'm building a custom module, and used hook_install and ...
1
vote
2answers
253 views
Convert a SQL database design to a drupal schema installation file
I have a, rather big, application that I would like to integrate into Drupal reusing the current database design / logic.
Is there a tool out there that can help me to build the PHP part of the ...
3
votes
1answer
54 views
Create MySQL View in hook_schema()
I want to create a MySQL View in hook_schema() for a module I am developing.
Does anyone know how to do that?
0
votes
1answer
65 views
Change CCK field data type
I have a CCK field with a data type 'text', that I want to change to 'decimal'.
I have used a hook_update_N and db_change_field in order to do this.
Here is an example how I tried to do it:
...
4
votes
1answer
56 views
what are the consequences of altering the users schema?
I was tasked with altering the signature/signature format and make the length larger than 255. Within the given time, I had to alter the table using hook_schema_alter, db_change_field and hook_update. ...
0
votes
0answers
31 views
Add a new column to a custom field module? [duplicate]
Possible Duplicate:
Update field schema
I have a custom field formatter module in which I specified two columns in hook_field_schema in mymodule.install:
function ...
2
votes
1answer
64 views
Change the index structure of fields in a table in database? Wise thing to do?
I'm on Drupal 7. The table index structure of users table is shown in the fig below:
As pointed out the table has two unique keys uid(also primary) and name which is the username of the user of the ...
0
votes
1answer
32 views
“jquery_file_upload.id is part of the primary key but is not specified to be 'not null'”
I have installed the jQuery File Upload module, and I get the following error:
jquery_file_upload.id is part of the primary key but is not specified to be 'not null'
What does that error message ...
1
vote
2answers
247 views
Must new tables be created in hook_update_N()?
When you create a new table in hook_schema(), should that table be added in a hook_update_N() as well? Or is there some trick, or something I missed, to have databae-updates automatically add tables?
...
1
vote
1answer
130 views
Alter schema on creating a new field
I want to create a module that on installing and creating a new field on a content type it should alter the schema of another module.
Im trying to use hook_storage_create_field to react on creating ...
1
vote
1answer
125 views
Why all dates columns in drupal are type=int and not type=date/timestamp/time?
I want to make this question short, so as title says "Why all dates in drupal are INT" ?
I've notice that in Schema API there was "datetime" but it was removed in D7.
Also all tables that have time ...
-1
votes
1answer
62 views
What is wrong with this schema definition and db query?
Hello and thank you for your time to help me in this weird case.
I have a schema API function that returns few database table information, and everything seem to work fine... except the most simple ...
3
votes
1answer
115 views
reseting the hook_update_n status of a module
I'm extending a module I've previously written and it needs some schema changes which I implement in hook_update_N.
I've updated the module's version from 7.x-1.0 to 7.x-1.1 and implemented the ...
2
votes
1answer
237 views
Can't create foreign key using SCHEMA API
I am trying to create 2 tables, linked together, using this code:
$schema['parent'] = array(
"fields" => array(
"id" => array(
'description' => 'The primary ...
0
votes
0answers
107 views
Extending image field to support additional content
We need to add a field to the standard Drupal Image field. This field will be used to store an id number of that particular image (so we can display a link to that image on the service: flickr, ...
0
votes
2answers
107 views
hook_scheme doesn't work [duplicate]
Possible Duplicate:
hook_schema is not creating database table
I am developing a module in Drupal 7. It is called scorm. I created scorm.install file, where I wanted to create the necessary ...
3
votes
2answers
1k views
How to create a table during the module installation
I'm trying to create a module for Drupal 7 and I need to create 3 tables and populate it. But first i need to create it.
In the file mymodule.install I have got
function mymodule_install() {
}
...
2
votes
1answer
843 views
hook_schema is not creating database table
The following function is contained in process_login.install as part of a custom module called process_login. The module works if I manually created the database table, but naturally I would like the ...
6
votes
3answers
145 views
Fields API vs. fields in hook_schema
Can someone please explain what is the advantage of using Fields API to create fields for an entity rather than just declaring them in hook_schema as values?
It's a bit of work to get all the fields ...
1
vote
1answer
145 views
.install file not working properly
I am new to Drupal, and I am trying to write a module with an .install file which will create a database table. The table isn't being created (as seen from the error codes when I try to access it. It ...
4
votes
1answer
126 views
Altering database tables belonging to core modules
Using D6's date_api.module module, I noticed that the .install uses db_add_field() to add a "timezone_name" column to the {users} table, and hook_schema_alter() to declare that change.
I was ...
1
vote
1answer
42 views
Specifying the length of an integer in hook_schema
Why does Drupal not allow you to specify the integer length with type int in hook_schema?
1
vote
1answer
460 views
How to define a timestamp field using drupal6 schema
In this way I can create a table with a timestamp field in MySQL:
CREATE TABLE foo (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
created_at TIMESTAMP,
name varchar(255)
);
Which would ...
6
votes
3answers
496 views
How do I specify in which database my schema should be created?
When using multiple databases in Drupal 7, how can I specify that a table is to be created in a different database on a different server?
By default, when you install a module, Drupal assumes that ...
1
vote
2answers
1k views
Schema not getting installed
I'm working the SchemaAPI but can't get it to create the tables. This is the content of my schema_test.install which is mostly copied form the examples modules.
<?php
function ...
1
vote
1answer
436 views
Database schema for image field
I have a module which behaves much like question and answers. Each question needs to have a help image. So far, I have written the schema as this:
function mymodule_schema() {
...
1
vote
1answer
461 views
'serialized' field in schema still needs manual unserialization?
I've modified my schema so that I can store an array of items in one field:
"required_product" => array(
"type" => "text",
"length" => 'medium',
"not null" => TRUE,
"default" ...
2
votes
3answers
193 views
How do I use curly braces in schema default value
I have a long varchar field that I'm using to save serialised data with drupal_write_record. I'd like to set the default value of the column to "a:0:{}" (which is serialize(array())).
However, when ...
6
votes
2answers
540 views
Is it always bad to pass a variable through t()?
I have a little helper function for my hook_schema:
function _bbcmap_schema_asr_field($description) {
return array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'small', // ...




