Questions tagged [database]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
546 views

Subdomain with shared database for users: subdomain not accessing primary database

I've successfully set up a multisite Drupal installation. I now have: www.example.com --> main site sub.example.com --> a secondary site However, I want the users to be shared. I know about shared ...
0
votes
0answers
15 views

How to capture the SQL on database errors

Is there a way to capture the SQL that was submitted to the database when the database throws an error?
1
vote
1answer
483 views

List nodes of children using taxonomy_select_nodes

I want to list nodes from children terms using or editing taxonomy_select_nodes function. Actually I added these few lines but I get an infinite loop or slow response: function ...
0
votes
1answer
4k views

Fatal error: Cannot use object of type stdClass Error help!

When trying to access my image file from my database i get this error: Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\drupal-7.25\sites\all\modules\database\database_ex....
1
vote
1answer
529 views

How to get Final SQL query when using Views?

How do I get complete SQL query from Views, the one I could run in mysql directly.For example biggest stumbling block is fields part. Like below SELECT users_node.uid AS users_node_uid, node.created ...
0
votes
1answer
575 views

Adding a 'OR' condition to query

I need to add a OR condition to my query so that I can get all nodes related to a particular term. Here is what I have done : $query = \Drupal::database()->select('taxonomy_index', 'ti'); $query-&...
3
votes
1answer
570 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('...
0
votes
1answer
827 views

What is causing Unknown field error in EntityFieldQuery API?

I am attempting to use the entity-field-query API to see if any node of referee content type has custom field that equals x. I've looked at dozens of code examples and references. (Included below) If ...
-1
votes
0answers
21 views

add a pdf generator [closed]

here is my question. in a custom module i want to add a button which returns a pdf file (with records from database). I can't use composer cause of using shared hosting. any ideas how can add this ...
0
votes
1answer
2k views

How to write SQL Statements With Spaces In Column Names

Hi I am trying to write a Dynamic Query to get data from the database but I am facing issues to write a query for column names with white spaces. My Product_Details Table looks as below: | S.No. | ...
0
votes
0answers
13 views

LOAD DATA LOCAL INFILE suddenly stop working [duplicate]

I have created a script that insert record from csv to data but it suddenly stop working on and I am getting error : General error: 2 File '/code/sites/default/files/data_file/CSVFile.csv' not found (...
3
votes
2answers
533 views

How do I store large volumes or data points using Drupal ( temperature and humidity points )

I'm trying to use Drupal as a headless API, and so far I'm having good results. One of the things I'm collecting is a Temperature and Humidity data. Thus far I've created an entity that can hold the ...
-1
votes
0answers
31 views

General error: 2 File '/code/sites/default/files/myfile/myfile.csv' not found (Errcode: 2) insert csv record in DB

I am getting an error while inserting CSV records in the database. It was working fine before, but now it doesn't. I am using MySQL 10.0.23-MariaDB-log. Drupal\Core\Database\DatabaseExceptionWrapper: ...
5
votes
1answer
53 views

What is the significance of dumping the tablespaces?

While recently running drush sql-dump on a server where there were never any error messages, I have started to get: mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(...
0
votes
0answers
12 views

Dump raw select query with parameters values

I would like to debug select query and I use the next code, for example: $connection = \Drupal::service('database'); $query = $connection->select('node', 'node'); $query->fields('node', ['nid']) ...
4
votes
0answers
766 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 ...
1
vote
1answer
30 views

Limit size of cachetags table

One of the site has fairly large cachetags table at over 418K records. Is there a way to limit the size of this table. This table is not cleared on cache clear. Since Drupal 8.4 there has been a way ...
0
votes
1answer
19 views

Dynamic query with left join

I need to collect comments that belong to certain user and submitted on pages of certain content type nodes. Currently I'm making two queries: $nodes = db_select('node', 'n') ->fields('...
5
votes
1answer
619 views

Drupal Commerce causing database deadlocks

I'm trying to get to the bottom of a known Drupal Commerce bug to do with row locking. When a user logs in on my development site, Drupal Commerce starts multiple identical queries that look like ...
0
votes
1answer
628 views

CURDATE() return wrong result

I have write sql query in drupal looks like this. Let's assume today's date is 2013-07-24 and total of node is 4. $query = "SELECT COUNT(*) amount FROM {node} n LEFT JOIN {...
1
vote
1answer
530 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 ...
1
vote
1answer
36 views

Is there a database lock mechanism?

I have a parent child entity relationship which is driven by a REST API. The payload contains data for both the parent and the child. The parent can have many children. When the (child) payload is ...
1
vote
2answers
565 views

Expand views visible fields with ajax

I'm searching for a module that can expand the number of visible fields in a particular view result with a mouse click. I'm probably not searching with the good words because I only thing I found is ...
0
votes
3answers
3k views

Unable to uninstall a module

When I try to uninstall the "Commerce license" module, the following error appears : drupal module:uninstall commerce_license [ERROR] SQLSTATE[42S02]: Base table or view not found: 1146 Table ...
0
votes
0answers
33 views

How can I fix this error I have when doing an update.php? [closed]

I have a Drupal 8 site under a Nginx server. I suspect that this problem is about the Ngnix configuration but I'm not sure. When I run update.php the problem displays under /update.php/selection ...
1
vote
2answers
680 views

EntityFieldQuery: number of field values as condition

I have a node type which has a field that can contain an unlimited amount of images. I want to retrieve a set of entities, but only entities that contain at least one image. So far this is my query: ...
26
votes
5answers
20k views

Using OR with EntityFieldQuery

I have never had the need to do this before today, but it doesn't seem like you can make OR queries with EntityFieldQuery, since db_or is used for select queries. An example would get to all entities ...
0
votes
2answers
2k views

Insert values into a node fields with entity wrapper

I've tried to use entity wrapper to create a new node and insert the values into the fields, but I get an error. <?php $values_entity = array( 'type' => 'anuncio', 'uid' => $userid, ...
2
votes
1answer
677 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 ...
1
vote
1answer
24 views

Check if the connection to the database is available

I have 2 databases, the first one with Drupal and the second one with external data. In a controller I want to read data from that second database and display it. As the external database can be ...
0
votes
1answer
75 views

Save boolean data types in serialized array

I'm writing a CRUD front end application that talks to a hand-written Drupal endpoint. The data I'm pulling from the database is serialized in one field, or cell. It comes out as a keyed array. One ...
1
vote
1answer
150 views

Fetch value from JSON

I have a field in drupal "field_xyz". it stores json values. JSON looks like this: {"Id_-_SiteWasteProductAction":"34638393224", "Postcode": "CSF 12CF"} I want to fetch postcode value from this json ...
0
votes
2answers
94 views

Converting a Views SQL query with INNER JOIN to an EntityQuery

I'm trying to create a custom JSON:API resource that returns the entities that have been flagged by a user. (The Flag module does not offer a way to get this out of the box.) I used Views to build a ...
1
vote
2answers
483 views

create a custom field schema

When I create a new field programmatically, drupal create a default schema for my being added and for each new field added is create a new database schema. I noticed that the columns always have the ...
0
votes
1answer
348 views

Custom join with an external database

I am trying to join two tables on the same database, db2. I am trying to join tablename to tablename2 using the condition tablename.ItemID = tablename2.ItemID. While the values from tablename are ...
0
votes
1answer
531 views

How to remove and add joins to a view?

Because of some buggy handlers I need to write a hook that will: Get location_instance table's alias from the original query Remove location_instance table join Remove that alias join Remove a ...
1
vote
1answer
624 views

programmatically create one bean block to the default theme

I am trying to programmatically create beans in a custom module using entity_metadata_wrapper. This is creating a bean for each installed theme. (In Drupal 7) Is there a way I can create only one ...
0
votes
1answer
565 views

Create bulk nodes - PDOException

Problem I'm trying to create multiple nodes at once using a CSV file for the data. However my script only creates the first 25 before it throws the following error. Any ideas what might be happening? ...
9
votes
3answers
1k 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(...
1
vote
1answer
899 views

query to retrieve all translations and nodes of a language that has been removed from the system?

I am experiencing an issue after a language has been removed from the system. Every time I go on the admin/content page on a drupal 8 site I get: Error: Call to a member function getId() on null ...
1
vote
2answers
15k views

How do I fix a “The requested URL /user/login was not found on this server.” error?

I am currently migrating a Drupal 8 site from one cloud server to another. The servers are Ubuntu and CentOS (AWS EC2) respectively. After copying the files and exporting-importing the database, I am ...
0
votes
0answers
36 views

Failed to update database after upgrading to 8.9.13

I'm new to drupal and was recently tasked with upgrading the drupal core version of one of our sites. I upgraded from 8.3 to 8.9.13 and everything went smooth enough until it came time to update the ...
1
vote
2answers
1k views

How to resolve the MySQL error Duplicate entry 'comment_publish_action' for key 'PRIMARY'?

I'm a beginner in Drupal. I want to import my database to my webserver and get this error when trying to do so: "#1062 - Duplicate entry 'comment_publish_action' for key 'PRIMARY'" I don't know ...
6
votes
3answers
2k views

Is there any compatibility issue with Amazon Aurora?

I'm exploring the possibility of using Aurora as a database backend for a large-ish Drupal 7 site because of the potential performance gains. Before I do that, though, I'd like to know if there are ...
1
vote
0answers
22 views

Double Publish is Required To Update Data When Node is Under High Traffic

We have a high-volume production site that is running into issues of serving stale data when a node is republished. Description/Example Of Issue I go into a node, create a new draft, then make some ...
15
votes
5answers
31k views

How do you build up a LIKE condition in a db_select() query?

How do you build up a LIKE condition in a db_select() query? I know how to do this with a db_query() API call, but is there a special syntax / method for doing this with db_select()?
2
votes
1answer
684 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....
1
vote
1answer
353 views

Migrating revisions from external data source

We are trying to migrate content from an external data source into Drupal 8 using the core migrate modules. This is a stripped down example of the data being migrated: id resourceId articleId ...
0
votes
2answers
35 views

How do I join two tables?

I was following this tutorial on Drupal module development. It talks about database query joins in module development. The tutorial is made for Drupal 8 and I'm using Drupal 9. Then I made this (look ...
1
vote
1answer
647 views

Select DISTINCT on a particular field

I want to return distinct values based on a particular column - 'company_code'. How do I achieve this? My code is as below. $query = \Drupal::database()->select('actuarial_bases', 'bases') ...

1
2 3 4 5
62