Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

4
votes
0answers
635 views

Why is my field definition update not working?

My module extends the existing image field type by 2 new fields, copyright and description. FieldType plugin: <?php namespace Drupal\image_extra_fields\Plugin\Field\FieldType; use Drupal\...
3
votes
0answers
93 views

Combining two queries

I want to list All the images that are present in more than one article. My setup is like this. I have a content type "article" and it has a field of type "Field Collection" (field_medias), the ...
3
votes
0answers
559 views

Using multiple keys on multi row db_merge?

I am using db_merge (mysql) for getting jobs into my queues. I therefore have each task only once (the job is quite intensive and many things can trigger the task to be queued, so want to avoid ...
3
votes
0answers
1k views

Fields with Multiple Entries in Views w/ External Data Source

I'm on drupal 7.9 and I'm using the Views 3 rc1. I've successfully created a custom base table that draws data from an external database (a drupal 6 site's database). Here's that code: <?php ...
2
votes
0answers
78 views

Per Bundle Storage for Drupal 8?

In Drupal 7 there was the start of Per-Bundle Storage (PBS) to try to store field data in a single database table if that made sense and was possible given the nature of the field. The PBS for Drupal ...
2
votes
0answers
381 views

entityQuery to get Nodes referenced by other nodes like an SQL JOIN

I have an entity query to get content of type article that has a field that matches a given value, which works as expected. $query = \Drupal::entityQuery('node'); $query->condition('status', 1); $...
2
votes
0answers
65 views

Design help for serialized classes that need database access

I want to convert from \Drupal::database() to dependency injection. I'm not 100% certain how to move forward with a refactor I know I have to complete. Currently I have a series of custom classes ...
2
votes
0answers
72 views

Is it possible to work with authenticated users that are never stored in the database?

I have to authenticate users against a remote authentication API. In the API's response there are several user properties, some of them mappable to a Drupal User some of them not. Because of legal ...
2
votes
0answers
453 views

How to query for entities where term reference field <> value

I'm trying to query for all entities where term reference field does not equal a certain value. For example: $query = $this->entityQuery->get('node'); $query->condition('...
2
votes
0answers
42 views

Query subrequest; convert procedural

I've got this request. SELECT COUNT(*), ( SELECT COUNT(*) FROM `node` WHERE uid = 1 AND type = 'article' ) FROM `comment` WHERE uid = 1 Currently, I'm executing this with 2 different ...
2
votes
0answers
40 views

Sharing data in the same database, being able to edit data

I am looking for a way for Drupal to be able to access and modify data in an external table in the same database. Both Drupal and the script need access to the same data. Duplicating/Migrating is ...
2
votes
0answers
215 views

Feeds SQL Import shows data in preview but fails to import

I have a problem on a client site with a Feeds import that shows the correct data within the import preview but does not copy the data across to the assigned field during the import. There are 18 ...
2
votes
0answers
59 views

Using Views without Database Support

We build a Drupal 8 based content management system that uses a triple store as the main data back-end. So we don't have any content data in Database tables. All CRUD operations on entities stored ...
2
votes
0answers
323 views

How do I resolve a PDO exception (SQLIte) error while deploying on Azure?

I'm deploying a Drupal site to an Azure App (do not have any choice in the matter, so no point suggesting other environments) and do not have access to it directly (no SSH) as it is a infra-structure ...
2
votes
0answers
31 views

My node.title differs from the title field in the database

I have a wierd problem i can't seem to get a solution to. I have a Drupal 7 website with more then 10000 nodes. And i recently discovered that 2000 of them have exactly the same typo in the title. So ...
2
votes
0answers
95 views

Update query not working

In a Drupal 7 custom module, I am updating a record in the database using a form, and I am using the following code to update, but for some reason it is not updating. Who can help me out? When I ...
2
votes
0answers
248 views

site down due to mysql error but returns 200/OK

A site I help administer was showing a MySQL error page, Additional uncaught exception thrown while handling exception. PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL ...
2
votes
0answers
65 views

Postgres errors with Metatag module in combination with Drag and Drop File upload

After having migrated from a MySQL 5.5 to a Postgres 9.3 Database I encounter some issues in a Drupal OpenOutreach installation. I have a content type with a Drag & Drop Upload field to display ...
2
votes
0answers
69 views

Create and update PostgreSQL view from Drupal view

Do you know about any way to automatically create and update PostgreSQL view from Drupal view? The reason is, that there are some applications, which can use DB view, but not Drupal one, such as QGIS ...
2
votes
0answers
183 views

Extend db query in CKEditor Link User module

The CKEditor Link User module has essentially the functionality I need, but it requires editors to know users by their 'name' field in the users table. I wanted to extend the query to join with the ...
2
votes
0answers
44 views

Concurrency when saving new comments

Taking a look at function comment_save() from comment.module, I can't understand how Drupal avoids duplicates when getting $max value on this statement: $max = db_query('SELECT MAX(thread) FROM {...
2
votes
0answers
203 views

Using join query / checking conditions with a table without unique key

User fields are: field_age (text field) field_sex (text field) field_vaccinations_taken (node reference field with multiple values, referenced to vaccination content type) Vaccination content ...
2
votes
0answers
54 views

Problem in creating instances (creating two sample modules)

I just started learning how to develop modules in drupal 7 using entities. I am creating two modules Artwork and Windfarm in artwork i am adding 2 custom fields (artist_name and Location) in Windfarm ...
2
votes
0answers
395 views

Creating a table for identical fields of two or more Webforms

Drupal 7 Webform 7.x-4.0-alpha6 I have two webforms with two fields in common; "name" and "e-mail". I want to display "name" and "e-mail" from all webform submissions in one overview table. The ...
2
votes
0answers
31 views

PHP interpreter dies during database.int/execute during file.api.php/file_save in fields/file/file.field.inc/file_field_presave

I Dont know what to say really. At the top level, im calling entity_metadata_wrapper.save on a user entity. This code has been in production for months The issue is during the save of a portrait ...
2
votes
0answers
83 views

Where/How to use a custom query in Views 3.5 D7

I have the following SQL query which produces the result I need in PHPMyAdmin and but I am lost on how I can use this query in D7. SELECT sum(month.field_oct_value) FROM uc_orders u, ...
2
votes
0answers
185 views

Replication failover mechanism

I am trying to set a master-slave environment for a Drupal 7 website. My concern is if the slave fails (with the current config) the site won't be accessible anymore. So, how can an automatic ...
2
votes
0answers
133 views

Problems arising while adding a new content type

In my website, I have created 42 different content types. I want to add one more content type. I can create the content type, but I am unable to add content in it. After creating a new content type, ...
2
votes
0answers
318 views

External script fails to load all drivers

Attempting to create an external script that allows me to query some things in Drupal. I was hoping to be able to use my external databases I have defined in the settings of my site to query some of ...
2
votes
0answers
556 views

Querying Matching User Data With Drupal and mySQL

I'm using Drupal 7 with the current mySQL version. I've got a custom profile field table that includes an entity_id (which corresponds to the user id) and a value field, which has one of a number of ...
2
votes
0answers
654 views

TF-IDF ranking for nodes with taxonomy term keywords

I would need to implement a ranking system that uses the TD-IDF http://en.wikipedia.org/wiki/Tf%E2%80%93idf Maybe it looks complicated but isn't Example: "Consider a document containing 100 words ...
1
vote
0answers
28 views

Optimize custom database queries

I am building my first Drupal 8 module and wondering how to optimize work with multiple queries to the database? $query = \Drupal::database(); $transaction = $query->startTransaction(); $product = ...
1
vote
0answers
26 views

For external data, should I create custom table or new entity type?

I have a database that exists outside of Drupal. I wish to show the summarized data from that database on Drupal. At a high level, you can see the structure of the data below. | Seller's ID | ...
1
vote
0answers
51 views

How can I drag and drop sort nodes and output result as JSON?

I have tried the DraggableViews module, but it creates a new table in the database that is not related with the entity fields of my entity and I'm using AngularJS as front-end with JSON API calls, so ...
1
vote
0answers
74 views

Method addWhereExpression does not consider fields without values

Tell me how to create the correct query. In its own handler filter for views, a $this->query->addWhereExpression query is created, where the fields in the nodes are selected. If all the fields are ...
1
vote
0answers
28 views

Database returning empty result from dynamic-queries

I have Tested the Query in PHPMyadmin and it work fine, then I use the Query Coder Module to build the query but it keep returning empty. I still went back to use PHPMyAdmin to cross-check it work ...
1
vote
0answers
21 views

OR Condition orConditionGroup() i

i have some Problems with the OR Condition in the WHERE part. Here is my function: public static function loademails(array $entry ) { $select = db_select('users_field_data', 'b'); $select->...
1
vote
0answers
41 views

Drush sql-dump with stored procedures

According to the current documentation I don't think this is possible, or is it? (drush sql-dump --routines doesn't work or anything like that) Aaaannndd... let's say it's not possible, and I want ...
1
vote
0answers
24 views

How to show view for a unique row from custom database table on Drupal 8?

I'm using drupal 8, and I have a custom table that was created with schema from my module on install file. $schema['md_noticias'] = array( 'fields' => array( 'id'=>array( ...
1
vote
0answers
788 views

Add Expression for Entity Query

I've been working with the entityQuery to query the db and get an array of filtered nids however I need to add an expression to my query. I've checked the Query class and found a protected sqlQuery ...
1
vote
0answers
180 views

Drupal 8 Search API not searching field collections

I have a content type called Basic Page with a few fields (title, description, page body), one of which (page body)is a field collection with a field called 'Section Body'. I created a view called ...
1
vote
0answers
144 views

How to debug AJAX entity wrapper error?

I'm writing a module and it's form aspects are fine, including fetching data from my database. I use entity metadata wrapper to fetch the field data from my database. I'm using data from a field ...
1
vote
0answers
31 views

Posting Data to an external site using APIs

I've been tasked with posting information from our website to recreation.gov, using their API http://usda.github.io/RIDB/ Is there a specific way using any sort of drupal module or built in PHP with ...
1
vote
0answers
219 views

Primitive type error when saving a node with a custom datetime field

I have a custom module providing a few fields to nodes - a checkbox, datetime field and a select. Previously the datetime field only contained date and the node would save correctly however since ...
1
vote
0answers
33 views

How to restore taxonomy terms and node relationships?

I was using the Delete Orphaned Terms module to delete unused terms. Today, bad things happened: it deleted lots of taxonomy terms although they're are not orphaned. Then I found a serious issue about ...
1
vote
0answers
25 views

Count the number of times a value is used

I have a situation where I have five columns in an external database I am accessing using the Views database connector module. Each column in the table contains a value between 1 and 5. I need to ...
1
vote
0answers
246 views

Move from utf8_general_ci to utf8mb4_general_ci

I'm in the prosess of moving several Drupal 7 sites from one hosting provider to another. It appears the new provider only supports utf8mb4_general_ci (MySQL 5.7.18). Is there a simple way to convert ...
1
vote
0answers
67 views

Access denied for database user message on production

Our live D7 site suddenly created the white screen of death, followed by an access denied message for the drupal database user. I was creating a new database for another version of the website in a ...
1
vote
0answers
46 views

How do I use the database abstraction layer with multiple databases in 8.2.x if I am using only raw SQL?

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%21database.api.php/group/database/8.2.x I'm not sure I'm understanding how to use Drupal with multiple database connections. I ...
1
vote
0answers
92 views

ANDs within OrConditionGroups

I'm trying to use entityQuery in Drupal 8 to perform an "and" within an "or" group. A simplified version of what I'm trying to do is this: Query for all apples, oranges and bananas that are ripe. The ...