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."

learn more… | top users | synonyms

0
votes
1answer
13 views

Is there a way to add a foreign key to a table?

My question is not regarding hook_schema but regarding hook_update_N: I need to add a foreign key to an existent table in drupal 7. I was looking Here but it does not seem to exist one explicitly for ...
0
votes
3answers
50 views

What entity should entity_id be joined on?

I'm writing a complex custom query to get order information from a Drupal Commerce install for export. The table "field_data_commerce_customer_address" has a column "entity_id." I've tried to join ...
0
votes
2answers
36 views

Drupal Schema Syntax Error

I'm building a module for Drupal 7 but having trouble with my schema and can't see what the issue is. This is my schema $schema['table_name'] = array( 'fields' => array( 'id' ...
1
vote
3answers
253 views

Cannot figure out what's wrong with my schema

It keep saying PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the ...
0
votes
1answer
55 views

Recieving PDOExceptions and missing fields and table on Module installation

I'm new to Drupal and it's pretty much my first experience of adding Modules. I've mostly being using the Migrate module so far in. On loading I'm getting PDO errors which are created by either ...
1
vote
1answer
135 views

Correct way to add custom column to user table?

I'm looking to add a column called 'updated' directly to the users table. The Field API and Joins are not an option for me in this case due to external constraints. How can I safely modify the ...
0
votes
1answer
55 views

db_add_field not working

I want to add a new field to node table using db_add_field when intalling a new module, but it seems there is something wrong or missing: here is the code used: /** * Implements hook_schema_alter() ...
1
vote
1answer
29 views

hook_schema duplicate unique keys

I am reading book 'Drupal 7 module development'. I am try to follow book to create a hook_schema (I delete some line for better read): function artwork_schema() { $schema['artwork'] = array( ...
0
votes
1answer
186 views

Table is not creating while installing the custom module in drupal 7 [Access Violation Error ] [closed]

I am creating a simple module. In that module I need to save the values in a table and I have created an .install file to create the table when the module is installed. While installing the module, ...
2
votes
1answer
65 views

How do I find the max length of a field (e.g. title field)

I would like to retrieve the maximum length of a field programmatically, for instance the $node->title field . I am writing a module that sets title and I don't really want to hard-code '255'. I ...
0
votes
2answers
138 views

Trying to create a table with an uid field that auto-increments and is the primary key, but keep getting an error

I'm working on an .install file for my module in Drupal 7. I want to create two tables, one called tls_connect_floormap_images and one called tls_connect_floormap_coords. I'm not having any trouble ...
0
votes
2answers
149 views

Table not creating while installing a custom module in Drupal 7

I am creating a simple module. In that module I need to save the values in a table and I have created an .install file to create the table when the module is installed. While installing the module, ...
1
vote
1answer
81 views

Problem with table schema

I'm working on an API that pulls data from a Drupal site. Everything has gone pretty well I normally use Drupal Bootstrap to load Drupal use the functions I need then spit out a JSON array. I am ...
0
votes
1answer
107 views

Panels & Views harm Google rich snippets (updated)

I Updated my question after further investigation of the problem (2/21/2014) I am building a site using Drupal 7 and the schema.org module and the microdata module. The site is live on production ...
0
votes
1answer
62 views

Can't add column to renamed table

When I first developed this module internally (not on Druple.com) the module_schema function created a table with the same name of the module (it was the only table, so it made sense. Short sighted.). ...
0
votes
1answer
35 views

Drop During Development

I find myself using Backup and Migrate's Restore (from manual backups folder) when testing module sets or after a change to a project is problematic. I use Schema after the restore to check for extra ...
0
votes
1answer
255 views

Auto increment using serial variable

In this code i want to incerment the value by 4 and not by one . How Can i do it ? select_id' => array( 'description' => 'TODO: please describe this field!', 'type' ...
0
votes
1answer
169 views

Help with PDOException and hook_schema()

I'm trying to set up an install file for a custom module that I'm creating but having a little trouble when Drupal tries to create my tables. It's probably a simple syntax error but can't track it ...
1
vote
2answers
482 views

Microdata or Schema.org (or both)?

I am building a community site in Drupal 7. I am using the SEO checklist, which suggest to use the microdata module. Other places I read are suggesting to use Schema.org module. what is difference ...
1
vote
2answers
118 views

How to create db table while installing a module?

I want to create a table in Drupal while installing a module (custom module which is crated by me). I tried in the below way, but I could not able to create a table in Drupal db. what am I missing, ...
3
votes
2answers
512 views

Which type to use for checkbox fields in hook_field_schema?

Task: Create a custom field which contains a single checkbox by implementing hook_field_schema etc. Question: Which data type is (or should) be used to define the corresponding database column to ...
1
vote
1answer
135 views

Need help clearing the schema cache [closed]

I am checking of a particular field type in the schema using: drupal_get_schema('MY_FIELD'); I see in the database the field type is int, but when I check after: ...
2
votes
1answer
250 views

How to create timestamp field? I get Undefined index: timestamp:normal in DatabaseSchema_mysql->processField()

I am getting the following error for the field within a hook_schema() Notice: Undefined index: timestamp:normal in DatabaseSchema_mysql->processField() (line 205 of ...
0
votes
1answer
153 views

How to include attributes of the MySQL table to hook_schema() schema in drupal 7?

I am creating a table using hook_schema() I am referring phpMyadmin to create a new table. In the phpMyadmin there is a column 'Attributes' which has values as 'unsigned' or on update ...
1
vote
1answer
840 views

DatabaseSchemaObjectExistsException: Table products already exists

I try to install my module, and everything goes ok, without an error while enabling DatabaseSchemaObjectExistsException: Table products already exists. in DatabaseSchema->createTable()... I ...
0
votes
1answer
268 views

What is the reason to define indexes in hook_schema?

How do I choose what fields to index and which ones not to? Is the index useful for when I set a condition in the database query for a quick look up of the rows? I guess this is an SQL question but I ...
1
vote
1answer
55 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 ...
5
votes
1answer
2k 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
339 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
2k 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
1k 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
219 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
92 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
78 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
46 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
629 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 ...
2
votes
2answers
2k 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 ...
6
votes
1answer
178 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
182 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
129 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. ...
3
votes
1answer
199 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
44 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 ...
5
votes
2answers
2k 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
105 views

Why timestamp format was chosen for users.created field

When I looked into users.created field in the database, it says, that is has type int. Does anybody know, why Drupal team chose this format instead of datetime? Cause timestamp will end with the end ...
1
vote
1answer
289 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 ...
2
votes
1answer
269 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
98 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 ...
6
votes
1answer
789 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
746 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
254 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, ...