Questions tagged [database]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
10 views

Problems in collations when restoring with drush

I'm quite lost with this issue I'm experiencing, so any clue will be appreciated. Let's start with the "symptoms". Whenever I restore a Drupal 7 site that has been previously backed up with ...
1
vote
1answer
456 views

Loading current revision node

How do I construct an entity condition so that it loads current revision of all nodes? This is my attempt. $query = new EntityFieldQuery(); $result = $query->entityCondition('entity_type', 'node') ...
0
votes
2answers
1k views

What code should I use, instead of running a query that uses DATA_FORMAT()?

I am converting Drupal 7 code to Drupal 8. In Drupal 7, I am using db_query(), while the Drupal 8 code is the following one. \Drupal::database()->select('node_field_data', 'spmw') ->fields('...
0
votes
2answers
3k 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
1answer
40 views

Get raw SQL query from Drupal::entityTypeManager

How can I fetch the raw sql version of the following statement? $t = \Drupal::entityTypeManager() ->getStorage('taxonomy_term') ->loadByProperties(['name'...
1
vote
1answer
821 views

How to return a missing field as null with db_select union?

I have a db_select union of two tables where some of the columns are different. I would like to select a column that is only in one of the tables. The standard SQL way of doing this seems to set the ...
3
votes
1answer
665 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 ...
0
votes
1answer
352 views

Error when upgrading to Drupal 8.7.1 on module menu_link_content

When running database updates (on domain.com/update.php) from 8.6.15 to 8.7.1, I got the following error: module menu_link_content Update make_menu_link_content_revisionable Custom menu links have ...
2
votes
1answer
411 views

Saving form data and running custom queries in mysql

I'm new to drupal and although I've researched and asked some questions I'm still stuck on how I can achieve my end result. I have built a php/html/mysql website (www.gbpokerclub.co.uk) but I now want ...
0
votes
1answer
422 views

How can I add multiple conditions for the same field taxonomy term in views query?

I make some query for views filter for nodes. Use in hook_views_query_alter. $definition = [ 'table' => 'node__field_characs', 'field' => 'field_characs_target_id', 'left_table' => '...
0
votes
2answers
608 views

Change max length of signature field to more than 255 characters

How can I change the max length of the drupal 7 signature field to more than 255 characters? I've already changed the sql data type from 255 to varchar(900), yet drupal still shows the error, as soon ...
2
votes
1answer
554 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 ...
0
votes
1answer
60 views

List all the nodes with the same menu parent ID

I have the following menu in my system. The parent menu-link connects to a node whose ID is 58. All the sub menu-links have a parent ID equal to 58. I need to find the main and the sub-menus using 58,...
0
votes
0answers
16 views

Altering user_admin_account and user_register_form

I'm pretty new to Drupal and I'm trying to build a Drupal 7 custom module to alter the user listings table in admin/people. I would like to display the first and last names of the users. I've already ...
0
votes
1answer
722 views

Search indexing slow query

Drupal 7.x The search module's indexing maintenance sql query takes a couple of minutes to complete each time cron gets triggered. SELECT t.word AS realword, i.word FROM search_total t LEFT JOIN ...
0
votes
0answers
20 views

Restore menu items using database backup

When working on a site I accidentaly removed all my menu items I now want to recover them from a database back-up I have. Is it enough to just copy all data from these tables from the backup to my ...
0
votes
1answer
451 views

File_managed URI change not working

Is there a way i can make file_managed URI changes in the database? I the database i have a list of files and there is append a _1 or _2 to the URI file name.i wanted to clean these up and remove the ...
0
votes
1answer
567 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 ...
1
vote
1answer
636 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
2answers
1k views

"Drupal already installed" Message on Restored site

We had an issue on a Drupal 8.8.2 site, had to restore DB, Core and Vendor, now anyone visiting the site gets the site as normal, but if admin logs in I receive: Drupal 8.8.2 Drupal already installed ...
0
votes
2answers
783 views

Drupal database not found after running update.php

after installing a module I run update.php and then click take me to front page or take me to admin pages the page takes a while to load and eventually gives me the following error: PDOException: ...
0
votes
1answer
34 views

Anonymous user redirected to core/install.php while admin does not

As an admin I've built a large table on Drupal 8 (php, mysql). It runs without issues for Admin, but trying as Anonymous user it redirects me to core/install.php Since it's ONLY affecting Anonymous ...
0
votes
2answers
604 views

Multi-site, multiple database and 1 shared database

I want to develop drupal multi-site with this structure: One shared codebase drupal 7 multi-site, each web site has own database. One master web site that has some tables shared. Each multi site ...
-3
votes
0answers
74 views

My website crashed after a mistake when creating a custom module; the mistake was fixed, but I can't flush all caches in a "normal" way

I can't use the GUI I prefer not to install Drush in my current localhost Windows 10 environment I tried the following which failed: Adding $settings['rebuild_access'] = TRUE; to the end of /sites/...
2
votes
2answers
433 views

Programmatically import users and create each for them organic groups

I have a function that allows me to create users from the data of an external database: function _loginuser_authenticate_validate($form, &$form_state) { global $user; // Use external ...
1
vote
2answers
5k views

Update multiple rows (with different ids and different values) using one query

I want to update multiple rows in a custom table using just one query. Each row has its own id (obviously) and different fields/values to update. Given this question and this post, i think i can ...
0
votes
1answer
889 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 ...
23
votes
4answers
12k views

Custom query in Views?

At some point I found the need to modify an SQL query generated by Views, in the end I overrode views_pre_execute and changed the query for that specific view. This feels like an ugly hack to me and ...
0
votes
1answer
368 views

Add custom operator for condition() in search_api

I am trying to implement hook_search_api_multi_query_alter but it seems 'IN' operator does not work here. I have to check condition on array. Any pointers for start building custom operator. function ...
0
votes
1answer
473 views

db_update query does not work properly

I work with views bulk operations and I wanna change status of selected items in a view. I applied db_update query, but something went wrong. I was debugging my code following: $status=$context['...
3
votes
1answer
584 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('...
1
vote
1answer
499 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
2answers
697 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-&...
1
vote
1answer
535 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 ...
2
votes
1answer
765 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
2answers
721 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: ...
1
vote
2answers
576 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
1answer
639 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 {...
0
votes
1answer
583 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? ...
1
vote
2answers
484 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 ...
2
votes
1answer
271 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 ...
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, ...
1
vote
2answers
2k views

How to create .install custom file [closed]

How do I create and add an .install file for Drupal 8 custom form data storage? My file is custom_form.install, but my custom module doesn't load this file. /** * Implementation of hook_schema(). */ ...
0
votes
1answer
537 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
631 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 ...
1
vote
1answer
1k 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
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 ...
3
votes
1answer
1k 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 ...
1
vote
2answers
2k views

Database query with notExists

I can't figure out how to select all aid's from the areas table that do not exist in the field_data_field_area_parent table. It almost works, except it returns Windy Ridge with an "aid" of "11". I ...
1
vote
1answer
465 views

Where in the MySQL database schema is the URL alias for a group relation?

I am building a report outside of Drupal that pulls data from a Drupal 8 database. The report shows titles of different nodes and I want to link those titles to the web page for that content. This ...

1
2 3 4 5
62