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.

-2
votes
1answer
16 views

When will doctrine ORM be implemented for modules?

I am looking at Drupal for some websites I want to set up. I have been a Symfony developer in the past so would like to use doctrine when I create a custom module. Is it implemented in 9 dev yet? Any ...
0
votes
1answer
16 views

Custom database connection

What is the best way to connect to a remote database through drupal? Would the correct method be to use the settings.php with the database in there, and use the built in db_select, db_query() etc ...
-1
votes
0answers
15 views

Cache and deadlock related database errors [on hold]

We have a module that performs fairly complex operations underneath the hood. Sometimes the processes exit with database related errors, since there are no exceptions thrown by Drupal core we can't ...
0
votes
1answer
20 views

How do I retrieve media from a reference field?

Inside a node type, I have a reference field to target a media. With a db select, I need to load all related medias of the nodes. For this I use this code: $database = \Drupal::database(); $result = ...
0
votes
1answer
21 views

where does drupal store list or collection data? [on hold]

I have to pull data from a Drupal database, and have field types which are 'List_Text'. Within the table for the specific field I have a xxxxxxxx_fieldname_value which is numeric and must be ...
1
vote
1answer
26 views

How to show the following n events with respect to the current date or the past events to always ensure n elements in the view?

I have an agenda on my homepage, and I want to always ensure 5 events. If there are 5 or more following events (including the current one), show the nearest 5 from the start date. If there is less, ...
1
vote
1answer
31 views

Delete in lieu of truncate?

If my DB user doesn't have permission to truncate a table - would using delete instead without any parameters be equivalent? So like - $this->db->delete('data')->execute(); in lieu of $...
3
votes
2answers
56 views

\Drupal::database() ->insert - Error: Call to undefined method Using ->condition()?

I am trying to insert a new row based on conditions. The ->condition() in $database->update() works fine, in $database->insert() they do not. $database = \Drupal::database(); // Query our ...
0
votes
1answer
20 views

Get default value of a node field

I have a field on a node which has a default value set, I need to access the default value of that field. But, I don't want to load any nodes of that type and access the field definitions, nor do I ...
-1
votes
0answers
26 views

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xC2\xAE TLC…' for column

I am using Migrate spreadsheet module for migrating data from xlsx file to a Drupal site. During the migration I receive the following error: SQLSTATE[HY000]: General error: 1366 Incorrect string ...
0
votes
1answer
11 views

Add a having condition that makes use of COUNT

I currently have a query that compiles to SELECT n.nid AS nid, field_data_field_date.field_date_value AS incident_date, field_data_field_tweeted_date.field_tweeted_date_value AS tweeted_date, n.nid ...
2
votes
1answer
53 views

How to configure mysql database connection with a different socket

I have a Drupal 6 site that I ran for years before walking away about three years ago. I would like to resurrect the site in a more modern CMS and am first considering Drupal 8. I run my site on a ...
1
vote
0answers
35 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
1answer
38 views

Use another field value as condition in Entity Query

I'm performing in Drupal 8 an entity query that searches for nodes that have not been changed since x days, where x is a numeric node field (node.field_days). So I would like to perform a query like: ...
0
votes
0answers
24 views

Is it safe to upgrade all the tables for 4 byte UTF-8 support?

I've a Drupal 7 website and it's a news website. To embed Tweets with smilies in my content, I had to add 4 byte UTF-8 support to the content table, following Multi-byte UTF-8 support in Drupal 7. ...
0
votes
2answers
40 views

How can I insert many field values under one term?

I'm working on a module, of which one function is grab list names and stock codes from a custom table and create corresponding terms. Now, my current code creates a new term and corresponding stock ...
0
votes
1answer
33 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
45 views

Custom query using EntityFieldQuery

I need to add a validation and need to check if an event booking (start and end time) falls under already booked time (start and end time). So far, I have done as below, but it is not working as it ...
-2
votes
1answer
26 views

Create dropdown list from values DB

I got some values from the database $result = db_select('node', 'n') ->condition('type', 'staff_members') ->fields('n', array('nid', 'title')) ->execute(); ...
0
votes
0answers
11 views

How to fetch records from entity base on 6 month

How to recover records from the entity database for the previous 6 months DATE_FORMAT (CURDATE () - INTERVAL 6 MONTH, "% Y-% m-01") is not supported For example: $database = \Drupal::database(); $...
-1
votes
2answers
71 views

MySQL through SSH tunnel

I'm trying to connect my Drupal 8 website to a mysql database hosted on a different server, which is only accessible through SSH. I can connect my database manager (heidiSQL) with a SSH tunnel, but i ...
0
votes
1answer
50 views

Display database query results in custom module

I have a custom block and I'm able to update its content using #pre_render if I'm using basic text. However I'm unable to print database query results using the same way. Below is my code. function ...
0
votes
1answer
54 views

Why am I getting Your system schema version is -1

I'm trying to make database updates to my Drupal 8 website, but I keep getting the error Your system schema version is -1. Updating directly from a schema version prior to 8000 is not supported., ...
0
votes
1answer
33 views

backing out of a module update after uploading it and before the database update (new update is incompatible with my version of PHP)

I got a situation here and I don't know what to do. Drupal 7. There's an update for reCAPTCHA so I click the button and checkboxes and whatever to update it, it uploads the files to the server and ...
0
votes
1answer
33 views

Is upgrading MySQL to MariaDB seamless for Drupal sites [closed]

My server has an outdated version of MySQL (5.5, which EOL'd in December). The WHM panel has an update option and the recommended upgrade is MariaDB 10.3. In theory (with all usual "test first" ...
1
vote
1answer
49 views

Left join query between two custom tables

Hi I'm trying to create a join query between two custom tables. One is publish_options with a pubid as the primary key. The other is publish_options_bundles with a referring field pubid to the first ...
2
votes
1answer
43 views

Have Database Update ignore prefix for multisite with shared database

I currently have a multisite with a single database. Each instance has a different prefix for their tables, except for one with no prefix which is considered to be the main instance. Now there is a ...
2
votes
3answers
48 views

Cannot uninstall modules due to missing table br_schedule

When I hit the Uninstall tab in the UI or try to uninstall a module with Drush I get the following errors: Drush: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DATABASENAME....
0
votes
0answers
32 views

How to get nid as int (and not as string) [duplicate]

This code snippet: var_dump( db_query("select nid, title from node limit 1")->fetchAssoc() ); Prints this: array(2) { ["nid"]=> string(4) "6247" ["title"]=> string(5) "test!" } ...
2
votes
1answer
25 views

Using the fetch() method in database query to get an array

I have a very simple query that does the job, to get a collection of a specific content type's node id and title, that's it. $connection = \Drupal::database(); $query = $connection->select('...
0
votes
0answers
24 views

Where is webforms template info stored in the database

I'm using webforms in Drupal 8. I have migrated an old database over but need to overwrite the correct webforms table to restore a webform template I created on a previous site. Can you tell me ...
0
votes
2answers
38 views

Which method is more efficient, database query or taxonomy term controller?

I tried to find a method to verify if the current taxonomy item page has a parent or children, now I get two but I don't know which one is better for the efficiency. approach I: use taxonomy item ...
3
votes
1answer
75 views

Database 4 byte UTF-8 support not properly checking

In the status report of my drupal website I got the message that I had to up Database 4 byte UTF-8 support. I updated all my tables and database like it's told here: https://www.drupal.org/node/...
-1
votes
2answers
76 views

Database Insert Slower On Production Server [closed]

I recently upgraded the PHP version to 7.1 on my production server. I also updated my local to 7.1 and staging to 7.1. Only on production, I am seeing a slow down when I import a csv file and insert ...
1
vote
1answer
30 views

Programmatically alter a field collection field item not yet saved in the database

Updating field collection field item gives error when one item is added. I have the following code which works well when just changing values of a field already saved in the database but if I add a ...
1
vote
2answers
45 views

How to get image path in view? [closed]

I have created a content type having two fields: Title Image (multiple image field) Then I create a page view for the same. Added these two fields. Now I have to create an external theming in view ...
1
vote
1answer
32 views

How can i use MATCH and AGAINST with db_select?

I have a query like: $query = db_query(" SELECT *, MATCH(field1,field2) AGAINST ('$s' IN BOOLEAN MODE) AS Relevance FROM {my_table} ORDER BY Relevance DESC, created DESC "); That ...
1
vote
0answers
42 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 ...
0
votes
1answer
43 views

How to display my array values in nested array of type stdClass Object

i am having trouble figuring out how to render my array fields values for specific fields. So far i've managed to query my db and collect the node values and save it to my cart of items. However, i am ...
0
votes
1answer
19 views

Finding entity/webform fields in the database

A bunch of user accounts were deleted and recreated with new UIDs, and so any webform submissions or entities that have fields pointing to the old UID are now broken/wrong. I already updated some UID ...
0
votes
2answers
48 views

Drupal db select IN, group by count

need a bit of help please, when i write my query like this it works fine $query = db_query('select * from form_submissions where address in (select address from form_submissions group by address ...
0
votes
0answers
21 views

If field name is end with underscore example field_data_my_field____ in Drupal 8 than what issue or failure can come

Suppose if I have created some field in content type example: node field . machine name (field_node_filed__) So what is the draw back of fields machine name is ending with (_) underscore. Is it ...
0
votes
0answers
32 views

Updating the delta value on a custom field

I have a content type with an image field and I am trying to update the delta value. I'm assuming the delta value is used to sort the images when they're rendered. (If there is a better way please ...
0
votes
1answer
436 views

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: [duplicate]

After entering some custom fields, I went to /content and now I am getting the following error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. I've tried the following with no ...
0
votes
1answer
47 views

Menus, drush uli link, and some images not working after moving site to localhost

I've just gotten a site I'm supposed to do some work on but I'm having trouble with migrating to a local development environment. I don't have admin access to the site itself, but I do have access to ...
0
votes
1answer
28 views

Conditional clauses with Entity field Query

I have a syntax issue on using conditional clauses with EFQ, but the documentation on drupal.org is a bit unclear for me. I have google the whole Internet for this with no results at all. My hook ...
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: ...
0
votes
1answer
24 views

How do i select all from database and do while loop with them

I did this easy select and im getting Error: Call to a member function fetchAssoc() on boolean , im beginner, im just trying to pull out two variables and make operations with them. $result = ...
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 = ...
0
votes
0answers
15 views

How to get / pull unique values from Database and not duplicates?

I have a multi-site and a database full of values that are identical, with the only thing separating them apart is the type of site. For example: Site1 = Myvalue1 Site2 = Myvalue1 Site1 = Myvalue2 ...