Questions tagged [database]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
567 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 ...
0 votes
1 answer
605 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? ...
0 votes
1 answer
665 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
1 answer
645 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 ...
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....
0 votes
1 answer
95 views

Update database issue

In 2 of my 3 Drupal websites, drush updb crashes with the following error after upgrading from Drupal 9.5.11 to Drupal 10.2.2. In BatchStorage.php line 143: [Exception] Serialization of 'Closure' ...
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 ...
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 ...
0 votes
0 answers
28 views

How to establish a database connection to Microsoft SQL server that has more than one server instance?

For an MSSQL database at the IP 192.168.55.55 and a server name of MYDB2, what should my database settings be in the settings.php file? (Please note, the machine has more than one database server, so ...
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 ...
0 votes
1 answer
433 views

db_fetch_object returning null

This is the line: $row = db_fetch_object($result); While $result is valid but $row is getting a null value which I've checked with is_null. As per this function's @return value, it can only return ...
0 votes
4 answers
869 views

How do I use bigdump.php with Acquia Dev Desktop?

I am trying to import a rather large database (~450MB) on my local machine (running Acquia Dev Desktop). To do this, I was going to use BigDump. However, I must not be configuring bigdump.php ...
0 votes
1 answer
670 views

Retrieve a list of values from a lookup table using db_select

I have a "jobs" table where each job can have multiple specialties. So I have a specialties table with a list of all available specialties and I have a lookup table that just has a job_number and a ...
0 votes
1 answer
3k views

How to write SQL Statements With Spaces In Column Names

I am trying to write a dynamic query to get data from columns with spaces in their names. The Product_Details table is the following. S.No. Product line Product type Product Year 1 Camp Equipment ...
0 votes
2 answers
697 views

Trying to create a table with an uid field that auto-increments and is the primary key, but keep getting an error

I'm working on an .install file for my module in Drupal 7. I want to create two tables, one called tls_connect_floormap_images and one called tls_connect_floormap_coords. I'm not having any trouble ...
7 votes
2 answers
20k views

Database query with like condition

Currently I am using the following query to select the data from database $result = db_query("select data from {config} where name like '%IPPOOL_POOL%' "); while ($row = $result->fetchObject()) { ...
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 ...
0 votes
2 answers
3k views

How do I get both published and unpublished records using entity query?

How can I get both published and unpublished records for a content type using entity field query? As per documentation we can filter records by status either published or unpublished. But I need all ...
0 votes
1 answer
587 views

SQL query to access a field collection's data? At them moment, I'm only getting field_collection_item returned

In the below example, I am trying to return the value of a field from all the field collections in the database but only get field_collection_item. This example is just the most basic field collection ...
2 votes
1 answer
851 views

Imagecache_external: Thumbnails of external URLs aren't accessible

Modules: Imagecache External, Media, Remote Stream Wrapper Scenario: I created a content type, in which I want to collect Movie Actors. My aim is to add images of those actors which arent hosted on ...
37 votes
4 answers
28k views

What's the proper way to use EntityFieldQuery?

In Drupal 7, the API documentation for node_load_multiple() says that using the $conditions parameter has been deprecated in favor of using EntityFieldQuery. In which way should EntityFieldQuery be ...
0 votes
2 answers
936 views

Can't insert data to database on form submit

I am trying to insert some datas into database table on form submit like this: function form_example_submit($form, &$form_state) { if ($form_state['values']['select']=='1') $gender = 'male'; ...
0 votes
1 answer
1k views

How do you check if table is empty before resetting the auto increment?

I have a database table that a user can add to and remove data from within my drupal module. What I would like to do is automatically check to see if the table is completely empty after every delete, ...
0 votes
1 answer
746 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 ...
2 votes
1 answer
2k views

What may cause Column not found (nid) in on clause?

I'm using Drupal 7.14 and Entity API and Reference 1.0-rc3. And I'm also using i18n, entityreference (not References) and field_sql_storage. I get this error when saving a node that has some custom ...
7 votes
2 answers
61k views

Why are we using utf8mb4_general_ci and not utf8mb4_unicode_ci?

Drupal is moving to support utf8mb4, however, it is using utf8mb4_general_ci. Why take the time to move over to support it, and then not fully support it? Is there a specific reason, or just ...
0 votes
1 answer
466 views

entity_load based on language selection

I have a node for different language, but I would like to load node for "en" language only using entity_load after firing entity query. How can I achieve it using this function in Drupal 7
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 ...
0 votes
1 answer
577 views

Insert multiple checkbox value from webform into table

I created: a webform named Test Number checkboxes checkboxes named Number with values one, two and three using Form Builder a table named checkbox_check Aim: When the webform is submitted, the ...
1 vote
1 answer
4k views

Connection timed out and lock_may_be_available() on working site

I'm hoping someone can point me to a fix. My drupal 7 app was running fine locally this a.m. while I was testing a way to insert a row using mysql tools for a non-Drupal function. My environment is ...
1 vote
1 answer
891 views

How to pass parameter to 'options list' attribute in hook_rules_condition_info?

I am declaring a condition in which I have the following parameters: 'node_type' => array( 'type' => 'text', 'label' => t('the node type'), '...
0 votes
1 answer
742 views

How can I query and order nodes with multiple date field values within a specific range?

I'm trying to get nodes that have date fields (multiple instances in some cases) and display them sorted ascending by start time for a given date. For illustrative purposes, here are some events and ...
1 vote
1 answer
50 views

Utility or command to clean the database from anything left from a contributed/custom module

Is there a utility or command to clean the database from anything left from a contributed/custom module which has been installed and successively uninstalled?
1 vote
1 answer
382 views

views_query_alter Matching all values in IN clause

I have a content type with a list(text) field. In which the admin can set multiple values on the field for the content type. Using a view the information is exposed to the end user. The views has a ...
0 votes
1 answer
527 views

Query returns 0 rows on JQGrid filter due to translated rows

I have a JQGrid table that can be displayed in different languages. The data for this table is stored as English text and translated when output. The JQGrid table can be filtered by text. The issue I ...
1 vote
1 answer
2k views

How do I create a TEXT column?

I am trying to create a TEXT column. function _mymodule_installed_fields() { return array( 'mymodule_summary' => array( 'field_name' => 'mymodule_summary', 'label' => $t('...
0 votes
1 answer
32 views

REGEX_REPLACE error when running DB query from update hook

This MySQL statement runs fine on MySQL 8.0.33-0ubuntu0.20.04.2: mysql> UPDATE node__body SET body_value = REGEXP_REPLACE(body_value, "<img.*base64.*>", ""); Query OK, 0 ...
3 votes
2 answers
1k views

Is transaction support enabled by default?

I happen to read through the commented lines in settings.php under the "Database settings" (around line no. 45) the following text: Some database engines support transactions. In order to ...
2 votes
3 answers
991 views

How to use curly braces in schema default value?

I have a long varchar field that I'm using to save serialised data with drupal_write_record. I'd like to set the default value of the column to "a:0:{}" (which is serialize(array())). However, when ...
0 votes
1 answer
90 views

How to let users write private letters to me about a node?

I want to let users the ability to write personal letters to me based on nodes they read while letters are stored in the Drupal database itself (no emails involved) and will include these fields: ...
1 vote
1 answer
509 views

How to extend TableSort class

I have a paged table that extends the TableSort class. The thing is, I would like to add some special parameters to the header links, so I need to extend the TableSort class. The problem is, it is not ...
1 vote
1 answer
1k 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 ...
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', $...
2 votes
1 answer
416 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 ...
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(...
1 vote
1 answer
463 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') ...
1 vote
1 answer
5k 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('...
1 vote
1 answer
585 views

Search and Replace URL in database?

I need to move a Drupal 9 website to a different server and a lot of links have the old server URL. Normally for Word Press I use this tool - https://github.com/interconnectit/Search-Replace-DB https:/...
1 vote
1 answer
467 views

Concatenate two fieds in an EntityQuery condition

I'm trying to query some nodes by a given string checking if the string is either in the node title OR if the string is an exact match of concatenating the value of two strings. I know this should be ...
1 vote
2 answers
97 views

Finding all nodes not referenced by a menu

I see this question was asked for Drupal 7, but the menu_link table doesn't exist in Drupal 9. Is there a SQL query for listing all nodes that are not assigned to a menu?

1
2 3 4 5
63