Questions tagged [database]

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

648 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10 votes
3 answers
2k views

LIKE clause not working in hook query alter

I'm trying to replace the default search with a LIKE clause in Drupal 7. I tried to alter the query according to Adding an OR condition to an existing query: function MYMODULE_query_node_access_alter(...
user9932's user avatar
  • 101
8 votes
1 answer
3k 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 ...
113408's user avatar
  • 326
5 votes
0 answers
57 views

Prioritise condition in QueryInterface

I have an overview with a search field. The query should search on both the title and description, but I would want to show my results that have the search parameter in the title first in the list. I ...
Cedric Lenders's user avatar
4 votes
0 answers
148 views

How can I dynamically switch between two databases for ALL queries?

I need to copy some entities from one Drupal 9 database to different Drupal 9 database. I have searched and looked high and low, but none of the examples I have found work anywhere. I found no help on ...
Martin Joergensen's user avatar
4 votes
0 answers
2k views

Schema information for module is missing - how to fix?

I tried to install the Scheduler module but it did not install properly because we somehow did not have code for another custom module that the database thinks was installed. I got the code for the ...
Stephen Ash's user avatar
4 votes
0 answers
947 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 ...
Paul's user avatar
  • 413
3 votes
0 answers
42 views

Speed up login after changing user name datastore type to VARBINARY from VARCHAR

We have a project underway that requires the import of ~6 million users into Drupal (Core 7x) that have many (150K+) case-insensitive duplicate usernames. Importing these users with existing case and ...
CMSW's user avatar
  • 31
3 votes
0 answers
1k 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 ...
mediaashley's user avatar
  • 1,084
3 votes
1 answer
68 views

How do I examine an entity's update SQL statement in order to write a unit test?

I have a core patch (https://www.drupal.org/node/2342699) which ensures that SQL updates do not include the primary key in the field list. I need to write a unit test for this issue and EntityApiTest....
Kevin Nowaczyk's user avatar
3 votes
0 answers
133 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 ...
lilott8's user avatar
  • 356
3 votes
1 answer
995 views

Is it possible to create a hierarchical exposed filter in views using the Data module?

I'm using Data module to adopt tables from the same DB as 'native' Drupal tables and Views module to present the data. I added two dropdown exposed filters with Selective filter module. It takes all ...
Khrystyna Zub's user avatar
3 votes
0 answers
1k 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\...
Alex's user avatar
  • 2,503
3 votes
1 answer
2k views

Changing decimal field scale and precision using database

I'm using a custom decimal field in a custom product type in Drupal commerce. It has a precision of 10 and a scale of 2 (2 digits to the right of the decimal place). I have a client with a large ...
Scott Lawrence's user avatar
3 votes
1 answer
108 views

Migration taking increasingly long periods of time

I have a migration and I've noticed that the code, through each batch operation, seems to process less and less items. For example, the first few cycles, it'll say, "processed 600", and 600 or around ...
Jack Ryan's user avatar
  • 2,297
3 votes
1 answer
728 views

Why does my site fail after restoring the database?

I tried migrating my Drupal live site to localhost to test it there. I followed the instructions in Migrating a site. Cleared the cache Disabled clean URLs Enabled mod_rewrite Then I backuped my ...
user2490392's user avatar
3 votes
0 answers
46 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 {...
Enric's user avatar
  • 31
3 votes
1 answer
595 views

How do you use hook_query_alter to get inside a query's creation?

I'm getting no love from hook_query_alter. I have a simple query to which I want to add a tag, while also adding a node_access tag. Thus the whole query looks like this: $the_nodes = db_select('...
Jim Miller's user avatar
  • 1,948
3 votes
0 answers
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 ...
Mike's user avatar
  • 31
3 votes
2 answers
173 views

How to insert ® value in database

I am inserting users from drupal6 to drupal7 using a custom script. I am using db_insert function. In one of the D6 entry I am getting ® mark in a field and because of this that particular value ...
avinashphp's user avatar
2 votes
0 answers
626 views

Installing to a MySQL database that requires SSL

I am attempting to install Drupal 9 to a fresh host using an AWS MySQL RDS instance for a database. The database is configured to require SSL. When attempting to install via the web GUI, I receive ...
thunderblaster's user avatar
2 votes
0 answers
161 views

Database dump without revisions?

Are there methods to exclude revision data in a database dump? The purpose would be to reduce the file size for developers that want a db dump for local development. I know that drush sql-dump has an ...
donquixote's user avatar
  • 3,632
2 votes
0 answers
214 views

How to add having to entity query Drupal\Core\Entity\Query\Sql\Query

I need to alter the query in getEntityIds method in PathAliasListBuilder i need only to get only paths with multiple path system: The sql select should be like: SELECT * FROM `path_alias` GROUP BY `...
berramou's user avatar
  • 7,175
2 votes
0 answers
188 views

database update warning but no updates - google tag module issue?

I'm on Drupal 8.8.2, and we've got a "database out of date" alert, requiring us to do database updates. When I attempt to do so at update.php, I get a message saying "no pending updates" I re-ran ...
turpentyne's user avatar
2 votes
0 answers
455 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 ...
gratrockstar's user avatar
2 votes
1 answer
925 views

cannot use some drush commands

I am running into some trouble with drush pm-enable: I cannot enable the modules I just downloaded. I did some research but none of the solution worked for me, most cases involved switching localhost ...
oproz's user avatar
  • 21
2 votes
2 answers
386 views

orConditionGroup() - unexpected result

$query = \Drupal::entityQuery('node'); $group = $query->orConditionGroup() ->condition('field_ref1_user.entity:user.uid', $user->id()) ->condition('field_ref2_user.entity:user.uid', $...
Igal's user avatar
  • 71
2 votes
0 answers
82 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 ...
jensjensen's user avatar
2 votes
1 answer
662 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 ...
ryrye's user avatar
  • 135
2 votes
0 answers
926 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('...
bkildow's user avatar
  • 712
2 votes
0 answers
53 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 ...
guish's user avatar
  • 61
2 votes
0 answers
1k views

Error 1146 Table doesn't exist checking "drush migrate-status" upgrading

I have found the next error when I tried "drush migrate-status" migrating from Drupal 7 to Drupal 8. Drupal 7.53 and Drupal 8.2.5 both with 10.0.28-MariaDB SLE 12 SP1 package. SQLSTATE[42S02]: Base ...
IMR's user avatar
  • 91
2 votes
1 answer
72 views

How does Drupal 7's SQL call for 'node' and retrieve an image?

I have the following query shown in one of my views: SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created, node.sticky AS node_sticky, 'node' AS ...
YPCrumble's user avatar
  • 482
2 votes
0 answers
45 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 ...
Scott M. Stolz's user avatar
2 votes
1 answer
119 views

Dynamically Caclulated Values with Entity Field Query

Is there any way to query by dynamically calculated values using Entity Field Query? Take the following: I want to query where the sum of field_some_number and a user-provided variable are greater ...
mjoyce91's user avatar
  • 131
2 votes
0 answers
55 views

Add custom entity search to Drupal core search

Is it possible to add results for a custom entity search to the results returned by Drupal core node search? At what point in the process would it be possible to add to the core search results? I've ...
nkanderson's user avatar
2 votes
0 answers
280 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 ...
raynimmo's user avatar
2 votes
0 answers
107 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 ...
user60062's user avatar
2 votes
0 answers
329 views

D8 Use Mongo for custom entity storage

Thanks to Drupal 8 new field storage architecture, we can read everywhere that we can use other database than Sql, for example MongoDb, to store fields data. I have a custom entity with some custom ...
rroblik's user avatar
  • 59
2 votes
2 answers
3k views

How to store data in database with Form API?

I'm new to developing Drupal 7 modules, and I can't figure out why my custom module's form data is not stored in my database's table called 'media_skins'. I followed the info explained in Creating ...
donbuche's user avatar
2 votes
1 answer
104 views

Drupal 7 multisite domain without www. not working

I have moved a site (www.example.com) to a multisite installation. The path is 'sites/www.example.com'. I am reading that adding the 'www' to the sites folder is a no-no. www.example.com - Works ...
Three_cs's user avatar
2 votes
0 answers
503 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 ...
WagnerMatosUK's user avatar
2 votes
1 answer
940 views

Field with unique and auto-increments values

I have a content type that in one of their fields need a value that is unique and auto-increment. There are several obvious solutions: Use the node id that is unique and auto-increment. The Serial ...
rpayanm's user avatar
  • 3,601
2 votes
0 answers
37 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 ...
jivanrij's user avatar
  • 157
2 votes
1 answer
778 views

How to add a correlated subquery expression in hook_views_query_alter?

In hook_views_query_alter, how to add a condition which is a correlated subquery in which the value of the condition is an expression? Given a view the produces this query: SELECT node.nid, node....
August1914's user avatar
2 votes
0 answers
115 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 ...
Noname's user avatar
  • 51
2 votes
1 answer
602 views

How to load taxonomy terms from user profile field using entityfieldquery()?

I want to write hook_node_form_alter() and limit taxonomy terms with only user checked terms on his profile in field_companies. I can't pass the 1st step - load array of user checked terms from ...
tlito's user avatar
  • 519
2 votes
0 answers
69 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 ...
leonis_csem's user avatar
2 votes
0 answers
88 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 ...
Miloš Kroulík's user avatar
2 votes
1 answer
35 views

How can I recover from a backup but include many changes from a dynamic site?

After the Drupageddon disaster, I've discovered that my backup plan is not sufficient. I have daily, weekly, monthly and yearly DB and file backups thanks to backup_migrate and backup_migrate_prune, ...
skulegirl's user avatar
  • 131
2 votes
1 answer
45 views

How to query drupal timefield data

Scenario: We have a bunch of events, each event has a date field, and a separate time field that has a start and end value. I'm trying to build a module pulls in the next event that hasn't ended yet. ...
Neil V's user avatar
  • 21

1
2 3 4 5
13