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

learn more… | top users | synonyms (10)

0
votes
1answer
7 views

Multiplied db_results when multiple IN

I am stuck since yesterday on a problem that is making me crazy, I feel like I am missing something. Here is the context: I am products (a node). In each products, I have tags (taxonomy terms), in a ...
1
vote
2answers
108 views

How to delete stuck batch?

What is a good way to delete a stuck batch in Drupal 7? It is on a production server, we are using the Background Batch module so it shows us which one it is at admin/config/system/batch/overview. I ...
0
votes
0answers
9 views

Trying to compare the fetched result with the user input

I am new to Drupal and I am facing some issues right now. I am making a hall booking website, so I have a table named "halls" with following fields: HallID, HallName, Capacity, Type, Price. I ...
0
votes
1answer
19 views

Placeholders must have a trailing [] if they are to be expanded with an array of values

In Drupal 8 I am trying to insert some data in my custom table. While executing query I am getting error: InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded ...
0
votes
0answers
9 views

Error “Mysql server has gone away” in long requests [duplicate]

I have a website in a server with mysql connection time is very limited. There is a feature where a http request is made and it takes more than one minute, and I get this message: Fatal error: ...
0
votes
1answer
47 views

Render database values using 'markup tags' other than 'table tags'

to keep things simple, I am trying to load a specific set of values from a database, which using the following code works: foreach ( database::load() as $bdt) { $row[] = (array) $bdt; } $content['...
1
vote
1answer
32 views

Drupal 8 : Disabling Menu Item Programatically

I have been trying to disable a menu item "standard.front_page" using the following code: db_query("UPDATE {menu_tree} SET enabled = 0 WHERE id LIKE 'standard.front_page';"); db_query("DELETE FROM {...
2
votes
1answer
44 views

Can Drupal 8 Not use utf8mb4

Due to an old version of libmysqlclient, we are stuck and can't deploy a completed site to our server. The client does not support utf8mb4. We have the datacenter who manages the server looking into ...
0
votes
1answer
22 views

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table

In my site, I get the following error: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cambodia_ohchrProduction.ohchr_cache_block' doesn't exist: TRUNCATE {cache_block} ; ...
0
votes
2answers
47 views

Add new field to custom content entity type

I have created a custom content entity type called Course. When I installed my module, Drupal automatically created the table schema for my entity, so all the fields I defined in Course::...
0
votes
1answer
24 views

How to display a select list label instead of the value programmatically

I created a select list box in the following format Gender 1|Male 2|Female I want to display the follwing information in a table but I am getting "1" for male and "2" for female. here is my ...
0
votes
2answers
36 views

How to store/manage/display data sets in Drupal without using the node/entity systems? [closed]

I need to store some straight forward data rows (similar to the JSON objects that can be stored in MongoDB), where all the data associated with one object is found on the same row and not scattered ...
0
votes
0answers
14 views

PDOException: SQLSTATE[HY000] [2002] No such file or directory in lock_may_be_available() [duplicate]

I have about 5 drupal sites on in motion server but for some reason all sites are showing me the same error which is "PDOException: SQLSTATE[HY000] [2002] No such file or directory in ...
0
votes
3answers
67 views

Inserting the value from Datetime field form

I have a form where the user can input datetime and then I want to store it in the database. Here's my schema : 'start' => array( 'type' => 'varchar', 'mysql_type' => 'datetime', ...
0
votes
1answer
38 views

How do I programmatically insert the entity ID?

I have added extra fields on the drupal 7 user registration form and created a module with a hook_form_alter function so that i can alter one field in the registration form. in the same file i also ...
0
votes
0answers
17 views

create new php file and add db_insert

I had created a new php file and place it in one of my module. I am trying to insert the data into database. $nid = db_insert('node') ->fields(array( 'title' => 'Example', 'uid' =&...
1
vote
1answer
38 views

SQL queries with AND/OR conditions

I'm transferring SQL statements from a Drupal 5 installation to Drupal 8, and struggling with And/Or condtions. eg given the original SQL: SELECT ..... WHERE ..... AND classes....
-1
votes
1answer
23 views

Execute substring

I want to execute a "SELECT " and the conditions use the " substring " postgres e.g:" SELECT * from desembolso_cnu WHERE substring(fecemi_pub,1,4)='2016'" How could I do with the use of db_select
0
votes
1answer
19 views

Two Errors Lumped Into One - File Field Deleted - Cannot Be Found/Deleted/Recreated

I'm in the process of adding more content types/cleaning up old ones on my site. Except I keep coming across an error that has another part which seems to differ from other questions posted to this ...
-4
votes
1answer
40 views

How could I delete products and products displays using mysql?

I am using kickstart commerce and feeds import to import my products in a csv. I need to delete some products and product displays using mysql in phpmyadmin because I had a bad import execution with ...
1
vote
0answers
18 views

Writing Drupal 7 queries using drupals DB abstract. (Similar to an entity wrapper)

Drupal (7) uses an abstact for handling DB-s. I'd like to write dynamic queries where i can use drupals abstract. There's entity wrapper for entities and I'm Looking for something similar to DB-s. ...
1
vote
0answers
15 views

DatabaseConnection Object - string does not reflect the object

So I've got a query object with the following data in it (outputted into watchdog) - this is from hook_views_post_execute() - [#conjunction] => OR [0] => Array ( [field] => ...
0
votes
0answers
28 views

How do I make changes in Views from dev to stage to production environment?

I am currently working on Production website. We are hosting our site in Acquia where we have Dev, Stage and Production environment. I have question regarding making changes in Views Block in ...
2
votes
2answers
120 views

What is the correct URI syntax for using Forena to connect to a Postgres database?

I am trying out Forena Reports and in connecting to a Postgres table I set the the Driver Type to Postgres Database and the URI to postgresql://username:password@127.0.0.1:5432/database. The problem ...
0
votes
1answer
33 views

How are SQL queries properly handled within a module?

I would appreciate a little guidance on where to begin so I don't waste a ton of time looking in the wrong places. I have a content type that has a number of associated entities appended to it; these ...
0
votes
1answer
35 views

Build-in query persist?

Is there a default Drupal 8 database persist function? Like as for Doctrine. for($i=1;$i<100;$i++) { $query->persist(); } $query->flush(); I want to collect first a lot of data and ...
0
votes
1answer
47 views

How can i write dynamic query?

Can anybody suggest to me how I can write a dynamic query in Drupal for the below MySQL query. Any suggestion will be appreciated. select * from capcup_passenger where passenger_uid not in (select ...
0
votes
0answers
18 views

Exclude from displaying, when we fetch data from db

My requirement is like: I am retrieving some data from 2 tables of a db,and displaying. Now I want to exclude from displaying,those data which is not present in third table. So how can i achieve this ...
3
votes
2answers
79 views

How to properly skip apostrophe in db_select?

In my mysql database I have texts full of apostropes which are used as stress marks. I need to implement keyword search ignoring these marks. I tested it first by using direct sql in PhpMyAdmin: ...
1
vote
1answer
25 views

Why do the database functions return all fields as strings?

db_select('my_table', 'a') ->fields('a') ->condition('a.campaign_id', $entity->campaign_id) ->execute() ->fetchObject(); my_table has some columns that are integers, but ...
0
votes
0answers
28 views

If I want to create a module that queries another database, do I put my SQL in the module?

If I create a module that queries a database that is not Drupal's database, do I simply put SQL in my module? Is there a way I can use Symfony services in Drupal 8 to do this? For example, SELECT ...
1
vote
0answers
38 views

Database in settings.php doesn't exist yet site is live. Where is the data?

I've inherited a Drupal 6 site running on an Ubuntu 10.04.4 LTS server. I'm trying to understand the configuration of it to create a local version of it work on. I can't figure out how the data is ...
0
votes
1answer
36 views

How to escape strings before insert query?

I've used mysql_real_escape_string to make strings safe before using Drupal. Must I escape string before inserting it to database? If the answer is yes, then how must I do it? I use something like ...
0
votes
0answers
8 views

Can adding new field to existing content type cause issues/side-effects in the future?

Are content types in Drupal protected against data corruption, that could arise from adding new field type and "something unforeseen" happening (ie field misconfiguration due to communication ...
0
votes
1answer
19 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
0answers
33 views

Load custom fields with entityQuery

I'm trying to load a user by it's uid via an Entity Query, this seems to work, however i'm missing my custom fields defined on the Entity User. I'm getting all the default fields like 'username', '...
0
votes
1answer
25 views

Select nodes based on entity reference value

I have a content type student, and it has an Entity Reference field named as field_offline_course_reference and a email field field_offline_course_student_ema I need a list of all emails of students ...
1
vote
0answers
19 views

db_create_table every month

Is it possible to create a table like "tablename_mmyyyy" from my module using hook_cron? db_create_table does not work. I need to create a new table every month.
0
votes
1answer
15 views

How can I update the field of the entity?

I have an "Question" entity, and I need to updates its 'key' field (of string type): My code isn't working: $storage = \Drupal::entityManager()->getStorage('question'); $query = $storage->...
0
votes
1answer
13 views

What are some specific reasons NOT to share a users database table between sites?

I'm building a site for a client, and surprise! Turns out they're using a shared users table between multiple Drupal 7 sites (completely different code bases, different config, etc). I'm only supposed ...
1
vote
1answer
26 views

Is it possible to detect access to table on site db table and redirect the db query to a db shared by multiple websites?

I'm working on a project where I use a database that is common to all sites and another that is specific to each. Is there a way to detect access to a specific table on a contrib module (maybe using a ...
-1
votes
2answers
27 views

Select fields from three tables using db_select()

SELECT u.`uid`,u.`name`,f.`field_user_first_name_value`,l.`field_user_last_name_value`,u.`mail` from users as u, field_data_field_user_first_name as f, field_data_field_user_last_name as l where f....
0
votes
1answer
15 views

Autcache + Varnish modules installed but cache tables growing

I have a site in Drupal 7, multilanguage and multidomain, and when I do a weekly manual database backup (apart from the automated ones), I see that the size of the mysqldump file is of about 200 Mb. ...
0
votes
0answers
11 views

Uncaught exception thrown in session handler

When logging into Drupal 7 website as admin, I'm getting the following error: UNCAUGHT EXCEPTION THROWN IN SESSION HANDLER. PDOException: SQLSTATE[HY000]: General error: 145 Table './...
0
votes
1answer
15 views

Creating trigger function in Postgres

I was developing my own customized module in Drupal 7. Is there any way I can create at run-time a trigger function in PostgresSQL? A sample scenario is when after successfully deleting a record in a ...
1
vote
0answers
16 views

PDO exception when try delete statuses [closed]

I am getting a PDO exception error when I am trying to delete a status update. There is a sub module in statuses module, Statuses Comments Flag Integration; maybe it has some problem. (In addition I ...
1
vote
0answers
41 views

ISSUE ACQUIA DEV TOP DRUPAL ALREADY INSTALLED

Well after 3 days of headsmahsing against this issue and trying to resolve it by reading the documentation available, I think it’s time to expose my problem. ^^ Every time I try to create a new web ...
0
votes
3answers
42 views

Use db_select with multiple conditions of which one needs to apply

My question is not a duplicate and it has complex conditions. Please let me explain. In my second condition, first I need to check if number value is correct (in first condition I checked complete ...
-1
votes
1answer
24 views

How to run hook_update for the database

Suppose we have a simple module with 3 files: test.info, test. install and test.module. test.install <?php function test_schema() { $schema['test'] = array( //fields 'fields' ...