Skip to main content
5 votes
Accepted

How to delete duplicate path aliases?

If there are many duplicates, use the queue system to delete them gradually. Start by enqueuing identified duplicates in an update hook: // file: my_module.install /** * Enqueue duplicate path ...
mona lisa's user avatar
  • 5,931
3 votes
Accepted

Database addExpression SUM: Call to a member function execute() on string

This is because addExpression() returns the unique alias assigned to the expression, and not the query. You can fix this by adjusting your code as follows: $query = $connection->select('...
Jaypan's user avatar
  • 17.6k
3 votes

database query's columnCount() and getColumnMeta() missing from core

It doesn't appear these were part of core in Drupal 9 either: https://api.drupal.org/api/drupal/9/search/getColumnMeta These appear to be PHP PDO functions: https://www.php.net/manual/en/pdostatement....
Jaypan's user avatar
  • 17.6k
2 votes
Accepted

Is the DRUPAL_DATABASE_HOST value stored somewhere in the database?

There is nothing named DRUPAL_DATABASE_HOST in the code or the database. The database connection details, which include the host, are written to the settings.php file during installation, and can be ...
Clive's user avatar
  • 167k
2 votes

Update database issue

As @4uk4 points out, this issue happened to me because of an old composer. Updating composer to its latest version and dumping autoload worked for me: composer.phar self-update composer.phar dump-...
TrilceAC's user avatar
  • 121
2 votes
Accepted

Drupal::entityQuery add CASE to have NULL values displayed last

You can add a tag to the entity query, and then use hook_query_TAG_alter() to manipulate it when it's been converted to a standard SQL query. e.g. $entity_query = \Drupal::entityQuery($entity_type) -...
Clive's user avatar
  • 167k
2 votes

Finding all nodes not referenced by a menu

In Drupal 9 can use this 'menu_link_content_data' table to find whether node has any reference as menu: Snippet code for finding all nodes not referenced by a// Get all nodes. $nids = \Drupal::...
mini_poojasharma's user avatar
1 vote

Error with Chado module installation

Turns out the error is due to table prefix. Table prefix is depreciated in latest versions and threw errors. Solved by removing the entire database (after backup) and creating a new one without prefix,...
s-135's user avatar
  • 11
1 vote

database query's columnCount() and getColumnMeta() missing from core

I'm guessing you had a custom patch in your D9 site, because even the predecessor (StatementWrapper) didn't have the methods you mention. You shouldn't patch the core class to combat this, instead you ...
Clive's user avatar
  • 167k
1 vote

Get the HTML content from the database

Drupal pages are generated in a complex way. Even the content stored in the database is often parsed by an input filter prior to processing. So you will need to use Drupal to generate each page you ...
Patrick Kenny's user avatar
1 vote
Accepted

Custom views filter plugin: filter over two fields of a custom entity where one of the fields is a multi value field in a seperate table

I think the easiest way would be to get all corresponding entity ids to this role and filter the query based on this ids. You can override the opSimple method of the inOperator for example with the ...
Chris4783's user avatar
  • 1,083
1 vote

Check which database is used

Using the following code, you can get the connection information that is set in the settings.php file used by the site where the code is executed. $connection = \Drupal::database(); $options = $...
James's user avatar
  • 11
1 vote
Accepted

Multiple primary key defined When importing DB to Dev

Azure MySQL Flex updated to MySQL8.0.30+ and had sql_generate_invisible_primpary_key turned to "ON" when the default should be "OFF". So essentially it's generating invisible ...
MetalBearSolid's user avatar
1 vote

Paragraph Entity Query returns too many results

If this returns 30 paragraphs then all of them were at some point stored in the parent node, but not necessarily in the current revision. It might be easier to load the node and then check the ...
4uk4's user avatar
  • 100k
1 vote
Accepted

Can I use entityQuery() in a Drupal 10 site to query entities from a Drupal 7 database?

The object returned from Drupal::entityQuery(), in Drupal 10, assumes the database has been created from Drupal 10. It will not work with a database created from Drupal 7 because Drupal 7 creates ...
apaderno's user avatar
  • 97.5k
1 vote
Accepted

Condition that deletes rows older than 30 days

Considering that the field Date is type date and has values with the following format: Y-m-d (2023-04-04). // Returns a timestamp equivalent to: 2023-07-01 17:20:53 UTC (today is 2023-07-31) $range = ...
Ricardo Castañeda's user avatar
1 vote
Accepted

DBTNG sentence that sums a column from all rows of a specific user and dpm the total

$query->execute() returns an object that implements StatementInterface. To get the table columns matching that query you need to either loop over that object or call one of the methods defined from ...
apaderno's user avatar
  • 97.5k

Only top scored, non community-wiki answers of a minimum length are eligible