Questions tagged [database]

Drupal provides a standard, vendor-agnostic abstraction layer for accessing database servers.

Filter by
Sorted by
Tagged with
2
votes
2answers
4k views

Transfer a site from SQLite to MySQL

Is it possible to transfer the content of a site that I develop locally with SQLite as a database to the live site which uses MySQL or PostgreSQL when it is finished? I don't want to have to install ...
5
votes
4answers
2k views

Login fails due to loop on localhost. Any ideas why?

I have git cloned a site and used Backup and Migrate to bring the database over the the local host. Working on the remote host the login works fine. Not locally. Well not anymore it worked for about ...
7
votes
2answers
3k views

mysql binary log makes disk full

Suddenly, I got my website down (drupal 6.19) and could not start mysql (too many tables got crashed). by checking df -h, I found that the MySQL partition is full due to very large binary log files (I ...
-2
votes
1answer
2k views

How do I change a MySQL query into a Drupal query?

mysql_query("SELECT nid,title, type,created, v_api.ContentSum FROM `node` n LEFT JOIN ( SELECT content_id, SUM(CASE WHEN value=1 THEN 1 WHEN value=0 ...
1
vote
2answers
3k views

How do I add an SQL query with hook_views_query_alter()?

I have the following SQL query: db_query("SELECT content_id, COUNT(*) as count FROM {votingapi_vote} WHERE value_type = '%s' AND value = 1 GROUP BY content_id;", "option"); If I ...
0
votes
1answer
65 views

During installation, the 'set up database' phase was skipped. Is that normal?

This isn't the first time I install Drupal 7 locally, but it is the first time that during installation the 'verify requirments' and 'set up database' phases were skipped. I did have databases set ...
1
vote
1answer
608 views

Please help with this query! Need to get taxonomy terms of related nodes

I've inherited this code that runs on our home page. It's used to do a custom display of specific pieces of related info. Here's how things are set up: We have an article. It has a series of node ...
0
votes
1answer
293 views

Which SQL query should I use?

I want to get the number of rows where the "value" field is equal to 1, and output its number and all the content_id where value_type is option in table votingapi_vote. the following is my code, ...
4
votes
3answers
3k views

How do I alter a view query to use “OR”?

The following is the content of the $query object that is passed to a view. [where] => Array( [0] => Array( [clauses] => Array( [0] => node.type in ('%s') [1] => node.status 0 ...
2
votes
2answers
2k views

Drupal schema API not supporting MySQL date data type?

I am getting this error with my existing database: no Schema type for mysql type date. I did some research and it seems like schema does not support date type in MySQL. What would you guys ...
2
votes
3answers
1k views

Problem with creating own module Block with an SQL query

I’m trying to create a custom module that implements a block to display something I haven’t been able to do with the Views 2 module. I’ve tried to look at some guides and tutorials, but I haven’t got ...
4
votes
1answer
499 views

Connecting to a database from another application

What is the proper way to do a remote connection to my Drupal database from a remote application? I am trying to integrate IPB with Drupal so I would like to modify my Drupal database from IPB.
2
votes
2answers
1k views

how do I troubleshoot an external database access?

I successfully setup a Drupal 6 site to access external databases and present them in tables via Views. Now I am trying to move to Drupal 7, and I'm not sure how to troubleshoot. In Drupal6, I can ...
6
votes
2answers
4k views

How do you build a query to get a series of nodes and their field values filtered by field values?

Hopefully someone with Drupal 7 experience can point me in the right direction. I'm creating a custom module to query some nodes and group and sort them by their field values. I tried to use Views ...
0
votes
2answers
747 views

How to update path alias using MySQL command line

Many words have been renamed in the node using the below code: update node set title = replace(title,'Apple','Orange') update node_revisions set title = replace(title,'Apple','Orange'); But now I ...
3
votes
1answer
302 views

Duplicate nodes returned from a module's SQL query

I'm in a spot of bother customizing the calendar block module for my needs. I've written a custom module that queries my database for published nodes that possess a specific taxonomy term. This works ...
2
votes
1answer
624 views

Updating a field value in database via submit handler doesn't update the user profile in UI

I've created the field "Attending" that is attached to the user profile. I have created a form with one checkbox element; when submitted, I've confirmed that the attending_fielddatabase is being ...
6
votes
1answer
7k views

Watchdog database size

I was checking out one of my Drupal sites and noticed that the watchdog table is > 3GB. I have plenty of space but it seems a big. Are there any best practices in regards to maintaining this table? I ...
0
votes
2answers
327 views

administer MSSQL databases from Drupal 6

Can you advise on a way to manage my SQL Server databases from Drupal 6x. I am using SQL Server for PHP driver (i.e. sqlsrv_connect()) to connect to my databases. Is there any module I could use to ...
0
votes
1answer
2k views

A function to get the term parent

function term_parent($tid) { $row = db_result(db_query("select * from {term_data} where tid = ?",array($tid))); if ($row['pid'] > 0) { $term = term_parent($row['pid']); $row['classid'] =...
2
votes
1answer
752 views

How to promote nodes to front page using MySQL command line

What is the command to promote unpromoted nodes to front page using MySQL command line? I want to promote 200 nodes at once. The node type is "story."
1
vote
1answer
567 views

FileField Database

I like the idea of using a field within a database to hold a file. Is it possible to store files within a database instead of within folders with Drupal 7? My current setup is Drupal 7, Ubuntu ...
1
vote
1answer
375 views

Is safe adding uid=0 in users table just to use $_SESSION?

I read many articles about adding it, but I'm not encouraged to use it yet. People says that Drupal doesn't add this user because MySQL Auto-increment starts at 1. So, about adding uid=0, is it a good ...
3
votes
1answer
895 views

Hook module and Drop table

I would know if it's possible to drop a database table created by a module. I could see the hook "uninstall" and "disabled" but nothing works. Can you help me please?
6
votes
2answers
855 views

Bulk update got slower after conversion of database tables to InnoDB

After I converted the database tables to InnoDB engine from MyISAM, I noticed some operations became very slow, especially on updating multiple nodes in bulk for administrative work. Front end ...
3
votes
1answer
1k views

Table locking again, am I doing it correct?

I had a problem with table locking, solved in this question: Table 'watchdog' was not locked with LOCK TABLES on custom module I want to share my current code, because I'm still not sure if ...
2
votes
3answers
2k views

Table 'watchdog' was not locked with LOCK TABLES on custom module

I am creating module that need to lock table: db_query('LOCK TABLES {eventi_list} READ'); $is_booked = _is_booked($uid, $nid); if (! $is_booked) { $is_booked = _is_booked($uid, $nid, '...
2
votes
2answers
371 views

Which database schema should I use?

I want to create a custom voting module to learn how to write a module. The vote table will contain four fields (id, title, vote_up, vote_down). Should I create a new table? If I create a new database ...
3
votes
2answers
2k views

db_affected_rows() return “1” when the query is wrong

I have a query like UPDATE user SET creator = 'creator'". The "user" table has not the "creator" column, so db_affected_rows() shoud return −1, not 1. Why? Update: mysql_affected_rows() returns -1 ...
2
votes
1answer
786 views

Table with sqlsrv driver is not showing headers or pagination

I just wanted to practice doing the table "header sorting" and pagination to display a Drupal 6 table using a simple MSSQL query. At the moment, the table headers are not showing and there is no ...
2
votes
1answer
163 views

How to alter each article's comment setting by PHPMyAdmin

After I updated my site, I found out that all the node comments are set to "disabled." I then went to the specific content type setting page, and changed the default comment setting to read/write, ...
1
vote
1answer
1k views

How to add a node field to a database table in a custom module

When I am writing my own custom module, and designing a database table, if I want to use the field nid to refer to a node, because I want my module to adding something to each node, how should I ...
12
votes
1answer
6k views

“init ”and “mail” fields in the users table

What is the difference between the "init" and "email" fields? mail varchar(64) User's e-mail address. init varchar(64) E-mail address used for initial account creation.
2
votes
5answers
289 views

Database Size, suggestions on Dev > Staging > Production

Our Drupal 6 Database is currently 75mb and the site has not even been launched yet. This is making it a bit difficult to export/import between our Dev/Staging/Prod as it is taking some time. I am ...
5
votes
5answers
644 views

Better site and database performance

I'm working on a Drupal community site and I want to ask about these things: How do I make a Drupal site more secure? How do I make my site work as fast as possible when there is a lot of visitors ...
1
vote
1answer
1k views

Multiple primary keys

I have defined a new content type, statetype and a CCK field, state. I need to use the CCK field as primary key in this table because I have another table and I need use that field as foreign key. (...
3
votes
2answers
2k views

What format are CCK dates stored in?

In what format are CCK dates stored? If it stores dates in the database using a timestamp string instead of a native MySQL datetime format, what implications does that have in regards to storing dates ...
1
vote
1answer
4k views

Adding Node-Fields to query with db_select();

I am building a query using db_select(); Now I need to sort my result by a field that a added using fields. Is there some nicer way than to join field_data_field_fieldname, and revision? I was ...
4
votes
2answers
430 views

Single SQL query to pull recent two nodes from each node type

As mentioned in the title, I was wondering how this can be achieved with single SQL query. All I need is the node ID from node table that matches the given criteria.
4
votes
2answers
2k views

MSSql or SQL Server Wrapper for custom module?

I'm writing a custom module and I need to access data that is currently stored in an MSSql database. It would be great if I could use the built-in database abstraction layer, but obviously that isn't ...
4
votes
1answer
2k views

How to test a MySQL connection

How can I test for active MySQL connections? I am trying to move one site to windows platform, and MySQL connections are failing; db_query() returns FALSE. I am not sure how to use drupal_test_mysqli()...
3
votes
2answers
274 views

developing a site in drupal made a mess in modules .. is there better way?

When I develop a site in Drupal, I test a couple of modules to see what best suits my needs. The problem is that, if it is a large site, I find myself with a lot of modules and patches (disabled / ...
0
votes
1answer
2k views

Drupal 7: Displaying external SQL-table as paginated list

The following code works well for displaying a paginated list of Drupal users: function generate_list() { $query = db_select('users', 'u') ->extend('PagerDefault') ->fields('u', array(...
8
votes
2answers
4k views

db_affected_rows in Drupal 7 for db_query

I just noticed that @Berdir was so nice to remove db_affected_rows from Drupal 7. I'm now wondering what the best practice is now to detect if the query you ran changed anything in the database. A ...
3
votes
2answers
3k views

Displaying SQL-table as a paginated list

I'm trying the following and it works: my.module: function my_menu() { $items['page_example'] = array( 'title' => 'Page Example', 'description' => 'Page Example', ...
-1
votes
1answer
1k views

When should the “translatable” tag be added to a query?

I noticed that a Drupal core function is using the following code: $categories = db_select('contact', 'c') ->addTag('translatable') ->fields('c', array('cid', 'category', 'recipients', '...
69
votes
3answers
12k views

Given that db_select is much slower than db_query, why would I want to use it?

For the background on this, please see http://drupal.org/node/1067802. Given all that, what situations exists where I might want to use db_select(), or should I be relying solely on db_query?
14
votes
3answers
8k views

NoSQL vs Other SQL Drupal Setups

What are the advantages of running NoSQL (ex MongoDB) over MySQL, PostGRE SQL or MSSQL in Drupal? Are the advantages gained from simply using the storage or does some Drupal configuration need to ...
17
votes
5answers
22k views

Is it possible to restore a deleted node?

While revisions are kept and it is easy to get back to a previous revision of a node, I was wondering if it is possible to restore a node that has really been deleted by a user?
20
votes
4answers
13k views

How do you make sortable tables with a pager with data from a custom table?

For Drupal 6 you could do something like this: $header = array( array('data' => t('Order id'), 'field' => 'order_id'), ... array('data' => t('Transaction time'), 'field' => '...