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
2answers
15 views

how to uninstall custom database table in drupal 6

I want to create custom table for my custom module "custom_module_table" /** * Implements hook_install(). */ function custom_module_install() { drupal_install_schema('custom_module'); } ...
0
votes
2answers
34 views

How to create table column type as TEXT in drupal custom module?

I try to create table column type as TEXT, i just can't find in Google, here's the code: function _mymodule_installed_fields() { return array( 'mymodule_summary' ...
0
votes
1answer
20 views

Tables are not creating with hook_schema

I need to create a module to save data of term page visits. <?php function term_count_schema() { $schema['term_search'] = array( 'description' => 'Stores timestamp range..', 'fields' => ...
0
votes
1answer
15 views

How to upgrade module table scheme for entity

I've written a module that uses entities functionality. It has the following table scheme in .install file: $schema['transaction'] = array( //fields 'fields' => array( 'id' => ...
0
votes
0answers
27 views

My fields don't appear in views after doing mymodule_views_data()

I've created a table in mymodule .install file. function secciones_schema() { $schema['seccion_empresa_contenido'] = array( 'description' => 'Contenido de la seccion de tipo "Categoría de ...
0
votes
0answers
40 views

Update failed - table doesn't exist

I'm running a D7 core update and all but one database updates pass. The one that doesn't pass gives me the following error message: Failed: DatabaseSchemaObjectDoesNotExistException: Cannot add field ...
1
vote
0answers
43 views

EntityMetadataWrapperException when updating Open Atrium

I've taken over management of a site using Open Atrium on the Pantheon hosting platform. The upstream repository was originally set incorrectly to Drupal 7 instead of Open Atrium. What this means is ...
0
votes
3answers
53 views

Add foreign key to schema using hook_update_N

I've written a module that establishes a child/parent relation ship between magazine issues and the articles in each issue. The idea is that by associating articles with magazine issues they can all ...
0
votes
1answer
30 views

Adding a new column to users table: db_drop_field errror

I'm trying to add a column to the 'users' table. When I install my module, the column gets created and when I uninstall it gets deleted. The issue is that after I uninstalled, I run a 'drush cc all' ...
-1
votes
1answer
29 views

Can't create table when installing module

I have a simple 'form_example' module and I want to add a database table when instaling module. I created this form_example.install file: <?php function form_example_schema() { ...
0
votes
1answer
44 views

how to update my custom table after execution of rules

i have created a table as follow <?php /** * @file * Implements hook_schema */ function core_sms_schema() { $schema['core_sms_details'] = array( 'description' => 'This table is used ...
0
votes
1answer
16 views

How to drop tables shown as Missing in Schema Report

During development/testing after using Backup and Migrate Restore in conjuction with Schema, Schema will show Extra tables no longer referenced in the database, used by modulesetc, and no longer ...
1
vote
2answers
46 views

How to remove a unique key in an update hook

I have a primary key and a unique key in my modules' schema. I need to remove the unique key. To remove an an index it is simple: function draggableviews_update_7205() { if ...
0
votes
0answers
37 views

Need help debugging a DatabaseSchemaObjectExistsException error

I'm getting this error both when I try to flush the cache and when i try to run update.php. I honestly have no idea where to start so any help is greatly appreciated. ...
0
votes
1answer
77 views

Adding new fields using hook_field_schema_alter()

I have an entity whose field schema is already defined and now I am trying to add couple of fields to it. But I am not sure how to code it up using schema_alter.Below is an example on how I would ...
0
votes
1answer
273 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
1answer
28 views

Schema relationship

The problems I am trying to solve are: 1- How can I connect tables defined by $schema to each other? 2- How do you insert data consistently into the database? Is there any possibility of having ...
0
votes
3answers
168 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
344 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
310 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
155 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 ...
3
votes
1answer
935 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
179 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
128 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
2answers
94 views

hook_install() doesn't seem to work, even though I have disabled and uninstalled module

I'm writing a module that will enable an editor to determine whether a script is available on a specific node, in order to improve page load times. I need to create a database table to hold an ...
0
votes
1answer
505 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
151 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 ...
2
votes
0answers
82 views

DB API: How to implement an enumerated field using hook_schema?

I need to have a field in my database that is shall hold a limited set of enumerated values. The MySQL ENUM type is not one of the predefined Drupal data types. So how do one implement a field to ...
0
votes
2answers
305 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
559 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
127 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
237 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
113 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
68 views

Drop Tables After Backup Migrate Restore

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
2answers
899 views

mymodule.install file not creating the table in drupal 7

I have a very simple table in my .install file and for some reason is not creating the table. What can it be? something i have to add in the .info file? please help. Its a drupal 7. this is what i ...
0
votes
1answer
621 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
285 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 ...
2
votes
2answers
1k 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
220 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, ...
4
votes
2answers
1k 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
268 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: ...
3
votes
2answers
155 views

How do I prevent the automatic removal of a database table when a module is uninstalled?

In Drupal 7, a database table created through hook_schema() gets created on module installation, and gets deleted on uninstallation. I would like to prevent the removal of a database table when the ...
2
votes
1answer
759 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
213 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
1k 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
679 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
73 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 ...
7
votes
1answer
4k 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
478 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
3k 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() { ...