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.

0
votes
0answers
12 views

key_value duplication errors after migration of the website

I have migrated my website from a server to another server. The only difference is that it went from a physical machine server into a containerized application. The server specs are the same and the ...
0
votes
1answer
24 views

How to specify AND, OR with dynamic query

I’m trying to create a dynamic query, the query logic conditions needed are: AND, and OR. The main query will include two sub queries. The ConditionInterface::condition documentation states that: ...
0
votes
0answers
12 views

Drupal Views3 Integration

How do I grant SELECT access for the Drupal user to all the CiviCRM tables using AWS RDS Database?
0
votes
0answers
11 views

Change date field; how to add timezone handling later

About date fields, this page https://www.drupal.org/node/767182 says If you start off without a time zone, but then realize that you need one at a later date [...] Perform the switch in the ...
0
votes
2answers
29 views

How to use between date query?

I have 2 fields in a node and I'm trying to get the expired nodes set in "Start Date" and "End Date" field. I'm using db_select to get the start and end date values. How can I add a condition to ...
0
votes
1answer
17 views

Dont save webform data to database

For SPECIFIC webforms, how can I make it not save data to the database, but just send the email? It should however still save the files and link to them in the email. Idk if I can use something like ...
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 | ...
0
votes
1answer
26 views

How do I add edit/delete buttons to a custom module items list? [closed]

I have a custom form on my development site for visitors to create requests, with 3 fields: name, contact, and request. This is the code in RequestForm.php. public function getFormId() { return '...
1
vote
2answers
43 views

Can I change the Display Settings by modifying the database?

I am using Drupal 8.5.6 and need to make the authoring information hidden for each content type. In other words, there should be no 'authored by admin on (date)' on any page. The fix should be simple (...
1
vote
1answer
35 views

How can I assign a database for each user?

I am new to Drupal and facing problems. I want to assign a database for each user where user can edit, delete or make entry to their database table. For example I want to develop a database ...
1
vote
1answer
18 views

Get all nodes where date field matches month and year

I have a content type with a date field (myFieldDate) whose values are timestamps. (I'm collecting only day, month, and year.) I have a custom form where I have a select list to select month and year....
0
votes
1answer
20 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
0answers
30 views

How do I access the database? [duplicate]

I want to access the database from my file, XAMPP/htdocs/PROJECT-NAME/getdata.php. I am using the following code. define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT . '/core/includes/...
-1
votes
0answers
20 views

Can we use the PHP extensions for database interface and PDO?

Drupal 8 supports MySQL, PostgreSQL and SQLite databases. In order to use MSSQL database we can use the community module SQLSRV. Microsoft has provided Drivers for PHP for MSSQL Server. The drivers ...
0
votes
2answers
27 views

db_select get value of the field

I have order form with field reference number. when a new order is submitted i need to get the last reference number. I did something similar long time ago in Drupal 7 but now i need to do it in ...
0
votes
1answer
30 views

How do I create a dynamic query that filters on month and day?

I want to get the list of the nodes, whose content type is Donors, where the date in the field_data_field_donor_date_of_birth matches today (except the year). How can I achieve it using a dynamic ...
0
votes
2answers
39 views

How to get the distinct number of the nodes?

In my task I need to get the distinct number of the nodes of some content type. How can I do it? $query = $this->connection->select('node', 'node')->condition('node.type', $type); $query-&...
0
votes
0answers
49 views

Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute()

I'm getting an error. This error does not allow me to access my site at all. Prior to the error, I could get modules, themes and such with no issue, but after the error, I can't even go to the home ...
0
votes
0answers
14 views

Having trouble to move site from Xampp localhost to live server with backup migrate module

This is Drupal 7 with Xampp on Windows 10. The migration is to live server with Siteground. For the sites folder, and files, it all works fine. Problems is with database, when I try to restore the ...
0
votes
0answers
23 views

Drupal removes ` (accent grave) around column “ `update`” in \Drupal::database()->update('table')->fields (PhpMyAdmin)

I use the following code to update my PhpMyAdmin database in Drupal 7. $qry = \Drupal::database()->update('table') ->fields([ ... ...
0
votes
1answer
66 views

How does Acquia Dev Desktop create the connection to the database?

I am using Acquia Dev Desktop 2 on my windows 10 PC in order to develop Drupal 8 websites. As far as I know, every Drupal website requires a connection between its files and the database which is ...
0
votes
1answer
25 views

How to sort the query results?

In my task I need to display the results based on "the newest first". I perform a query: $query = \Drupal::database()->select('node_field_data', 'node'); $query->innerJoin('...
0
votes
2answers
30 views

Condition on $user_storage

I am using the following code. $user_storage = \Drupal::service('entity_type.manager')->getStorage('user'); $ids = $user_storage->getQuery() ->condition('status', 1) ->...
-1
votes
2answers
36 views

How to use drupal_write_record for updating a custom table?

I am using the following code to add rows to a custom table used from the module I created. $my_query = db_query("SELECT to_date FROM table_name where to_date = '$to'"); $num_of_results_service = $...
0
votes
1answer
56 views

Recreate admin user

My login to Drupal 8 instance has failed. ive had a look in the DB and in the users table are 3 entries i dont recognise and the admin username (say 'adminuser') ive been using for the last year (but ...
-1
votes
1answer
48 views

How do I programmatically check whether a custom entity is stored in external database?

In Drupal 8, how do I programmatically check whether a custom entity is stored in the external database using the entity ID? Do we have any method/service to check whether a custom entity is stored ...
0
votes
1answer
22 views

How can I insert a variable into query condition?

I am writing a query, and the question is how can I insert an array variable into condition statement. So instead of having (1060,968,1106) I would like to place there an array. $fields; // array ...
0
votes
0answers
30 views

Use addWhereExpression function

Somehow I am not able to write a query for filtering a view. I don't understand why the below script is not working: function xxx_views_query_alter(ViewExecutable $view, QueryPluginBase $query){ ...
0
votes
0answers
24 views

How to update all instances of field with a santitized copy of another field

I want have added an extra field to a table and want to use db_update in hook_update_N to populate it with a sanitized copy of a preexisting field. Just copying a pre-existing field is trivial if one ...
0
votes
1answer
45 views

How to query a map field

I am developing the Spectra Analytics module on drupal.org, and one of the interesting new features in Drupal 8 is the ability to create "map" fields in the database. These fields are simply ...
0
votes
2answers
44 views

How to delete a database field named as a reserved word?

I want to drop a field from db table which is named as read. I tried like; db_drop_field('my_table', 'read'); db_drop_field('my_table', '`read`'); db_drop_field('my_table', `read`); None of these ...
1
vote
0answers
37 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
1answer
33 views

For a customer database table, do I have other options, beside creating a custom module? [closed]

I'm upgrading my site to Drupal 8. Currently, I have a custom module with a custom database table and I query that to provide historical data that is in the table. The data is really purely tabular ...
0
votes
0answers
34 views

Creating a column in mysql to store uuid

In Microsoft SQL we have UNIQUEIDENTIFIER type while creating table and when inserted it fills auto-generated string into that row. Is there any equivalent type in Drupal 8 or should I use some ...
0
votes
1answer
35 views

entityQuery with multivalue date field

Is there way to use entityQuery in order to select nodes with multiple value date field. For example we have a content type event with a field field_event_date which may contain unlimited number of ...
0
votes
2answers
39 views

Select data from database

For the filter block I need to get the data from database. I have three tables "node", "node__filed_country" and "taxonomy_index". So I need to pull only those taxonomies which are realted to the ...
0
votes
0answers
30 views

Very slow menu_tree_check_access query - how to debug

I have a Drupal System which is running fine in production and locally but the dev/cons Db seems to have a problem. After looking a bit deeper into it I found that menu_tree_check_access takes 3.8 Sec ...
0
votes
0answers
21 views

Should I even bother using OPTIMIZE TABLE on my cache and watchdog tables?

Been ignoring my OPTIMIZE TABLE warnings for about a week now, as the project I'm building is still in dev and not much has used the db yet. Today I finally went into MySQL Workbench and ran the ...
0
votes
1answer
27 views

Use created year as condition in Entity Query

I'm performing an entity query that searches for nodes of my custom content type called 'news'. I want to perform the query in a way that only produces the 'news' nodes that have a Authored Date that ...
0
votes
0answers
15 views

How do I use addExpression() with a where/having clause?

I need to use the uses field in a having clause. Googling, I found it should work, but I get an error about uses being a not existing field. I tried replacing uses with count(*), but I get the same ...
0
votes
0answers
31 views

EFQ with huge data

I'm using EFQ to load nodes. However when the data is huge the page naturally breaks. Is there a way to lazy load the EFQ result or any idea how to optimize it? Noting that the client doesn't want ...
0
votes
2answers
49 views

Help with database query

How can I convert this sql query into a Drupal 8 query? I need all nodes of type 'page' that has not been referenced by nodes of type 'article'. Article content type contains an entity reference ...
1
vote
0answers
47 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 ...
0
votes
1answer
19 views

Entityreference not saved correctly inside ContentEntityForm

I was having a weird bug with my views. Some entity-references from my main-entity didn't show up in my view. I investigated further with entityQuery and came across some weird action. I can get the ...
0
votes
0answers
29 views

how to get all orders filtered by one product using EntityFieldQuery?

The below code will filter by date but what i really need is to filter by product. $query_invoice = new EntityFieldQuery(); $query_invoice->entityCondition('entity_type', 'commerce_order') ...
0
votes
0answers
21 views

EntityFieldQuery and use the statistics module

How to get 10 entities with the best number of views per day (daycount from statistics module) with EntityFieldQuery? My code that displays the entity, but how to get the best views? function ...
-1
votes
1answer
27 views

js in default/files causes extreme slowdown of website [closed]

for the past week my website is plagued with over 4000ms hanging upon entering, more so at sometimes. After using firefox's performance monitor, I pinpointed it to several lines of code in a js file ...
2
votes
2answers
458 views

Site not working after the database update

I cloned a repo of a site to my local computer, imported the database and ran "Composer install --with-dependencies" after the installation had been done I entered the local site and it worked, then I ...
0
votes
0answers
18 views

problem with db_select, ->condition dont work if compare a field with a value

im trying to make a field with the results of a sql in php . im trying to make a condition with the field "manifestacionType" and compare with value 'compuesta'. The problem is that i dont know to do ...
0
votes
1answer
55 views

Views relationship to second database

Is there any possibility to add a relationship in views from a second database to the default one. I.e. I am using a second database which contains one table with a userid. In my hook_views_data I ...