Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [database]

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

4
votes
0answers
730 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
105 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
611 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
1k 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 ...
2
votes
0answers
75 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
75 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
126 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 ...
2
votes
0answers
559 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
45 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
41 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
225 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
61 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
362 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
32 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
97 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
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
70 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
186 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
70 views

Getting weird ambiguous column error message in where clause when accessing database

I am getting an error that one of the columns I am accessing is ambiguous in my where clause. While I understand what that message means, I believe that my code is set up correctly to avoid such a ...
2
votes
0answers
204 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
401 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
84 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
188 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
666 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
38 views

Should I use custom entity types and custom fields to represent complex data types, or is it better to stick with fields and field collections?

Since D7 is now coming up on EOL I need to begin planning the transition of a complex D7 site to D8/9. There are 2 particular data design issues I want to revisit. Number one is that I have a number ...
1
vote
0answers
46 views

entityQuery where a translation with a different value returns incorrect nodes

The title seems a bit odd, I know, but I couldn't find any issues similar to this and that's the best I could come up with. We are running into an odd instance of entityQuery returning nodes that ...
1
vote
0answers
12 views

Select locale translation info from non-default database

I setup 2 databases connections in settings.php, one is MySQL on which Drupal is installed and running, the other is Oracle from which sometimes reading some info non-relevant to Drupal as below: ...
1
vote
0answers
41 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
126 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
121 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
190 views

Entity query - using parent/grandparent ids as a condition

I have relationships linking a node to a child paragraph, with a grandchild paragraph: Node |_ paragraph child |_ paragraph grandchild Using an entityQuery, I can get child items using ...
1
vote
0answers
151 views

Ignore table if it exists on module install

In my module I am using hook_schema() to create an empty (custom) DB table when the module is installed. However, there are some use cases where the module would need to be installed when the table ...
1
vote
0answers
39 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
26 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
1k views

How to repair “Mismatched entity and/or field definition” when “drush entity-updates” fails?

I'm developing a site in Drupal 8 in Acquia Dev Desktop 2 on Windows 10. After updating to 8.5.0-beta1 I noticed this error on my status page (although it may have been there earlier in 8.4.4): ...
1
vote
0answers
54 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
224 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
171 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
35 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
271 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
43 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 ...