Topics related to the database API implemented by Drupal.

learn more… | top users | synonyms (1)

0
votes
0answers
20 views

How to save nodes using Drupal::lock() or db_transaction()? [on hold]

I'm wondering if you can save nodes programmatically using a notify endpoint. The idea is that a remote server will hit an endpoint on my Drupal website, and trigger changes to nodes. It's working ...
0
votes
1answer
25 views

Using SQL to output link to a node

Does anyone know - using SQL only - how to output the link to a drupal node? If I was using PHP I think it would be something like this: print l($node->title, 'node/' . $node->nid); But I'm ...
0
votes
0answers
29 views

D7 db_update — how do I get the unique ID (primary key)

I am working on an edit/update function in my module. I am able to populate the form with the correct data based on the unique ID but am unable to pass this to my submit_handler function. Submit in ...
1
vote
1answer
15 views

How can I make db_query SELECT LIKE case insensitive?

I'm querying for an email address where I can't force the case of the search term or the data in the table. It's an API thing. How can I convert this query to be case insensitive? $results = ...
0
votes
1answer
29 views

db_select sub query

I need to use sub query on db_select but, as you can see the sql, I think the first select should be like db_select('tabe1','tab') but this table is a "virtual" table I've to create temporary only for ...
1
vote
1answer
21 views

How do I add a COALESCE to a db_select?

I want to achieve the following query using db_select(): SELECT Column1, Column2, COALESCE(Column1, Column2) AS Column3 FROM TEST_ATTRIBUTES How do I add the coalesced column to the ...
1
vote
2answers
32 views

DB Query exclude duplicates, returning only the newest

I need to alter the query below to only return one row for each unique 'name'. The row returned should be the most recent based on the contents of 'date'. 'date' is an integer. $query = ...
2
votes
1answer
28 views

Error when trying to extend a db_select query

I'm trying to add a field to my query by using addField(). However, whenever I add this to the query I get a whitescreen and an apache error message on the line after. Any help in resolving this would ...
0
votes
1answer
10 views

How do I reset a user's name using Drush in Drupal 7?

To change a password I would use: drush user-password USERNAME --password="SOMEPASSWORD" Is there a similar way to change a user's name using Drush from the command line?
1
vote
2answers
25 views

Use Firebird Database to Lookup Data

I have installed my drupal in postgres. I've been using multiple databases in my customized module. Below is my settings.php: $databases = array ( 'default' => array ( ...
0
votes
0answers
26 views

Use OrderBy in Query

I want to retrieve only the latest course of the student which is BSCS in my semstudent table, so I sorted it out by using orderBY sy and sem. Below is my code: $query = db_select('student', ...
1
vote
1answer
34 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, ...
0
votes
1answer
37 views

“the website encountered an unexpected error.Please try again later” after db_update

Drupal responses "the website encountered an unexpected error.Please try again later" after running db_update statement in my custom module. I always do this without any error. Any suggestion pls! ...
0
votes
0answers
26 views

Fetch result of query twice

I faced with problem while fetching query results, my code: $result = $query->execute(); $array1 = $result->fetchAllKeyed(1, 0); $array2 = $result->fetchAllKeyed(2, 0); But the $array2 is ...
0
votes
0answers
30 views

Search on field collection with EntityFieldQuery

I have a node resource with fields name files (field collection) And field collection with fields title path How can I search all node have file title = 'example' How can ...
0
votes
1answer
18 views

db_insert error delta “doesn't have a default”

When I execute this code: db_insert('field_data_field_room_rates') ->fields(array( 'entity_type' => 'node', 'bundle' => 'rooms', 'entity_id' => $roomno, 'revision_id' ...
0
votes
1answer
33 views

db_query question

I'm writing a custom module and trying to use the db_query functions instead of just doing straight MySQL calls. Here's my query. $nid = $node->nid; $result = db_query('SELECT * FROM ...
0
votes
2answers
93 views

How to get the field values with EntityQuery?

I am working on a query filtering form that lists entities. I have various 'range' fields and I would like to display the min and max values. Is it possible to retrieve field values with EntityQuery? ...
2
votes
2answers
88 views

OWASP security and drupal

Recently, To improve our site security we implemented and enabled OWASP security in our server using mod_security. After we enabled the OWASP security, whenever I try to create or edit contents in my ...
1
vote
1answer
59 views

EntityFieldQuery with pager and db_or using addTag

I'm having an issue that I hope some of you can help me with. Drupal version: 7.36 I've created a list of all nodes of a certain content type using EntityFieldQuery. Since there are a lot of nodes ...
0
votes
1answer
34 views

Get logged in user id in api calls

I am working on an existing site where it has exposed api's via a custom module. There's a new requirement where an api should only be accessed by authenticated user. For that theres a login api ...
1
vote
1answer
23 views

Load file of content by weight

Let's suppose I have a simple content type with title, body and file fields, and file field is multi value. I create a piece of content and upload some file in my field. Finally my content is ...
0
votes
2answers
54 views

how i could use limit() on db_delete? [closed]

could someone answer on how i could use range() on db_delete?? $values_to_delete = db_delete('errors') ->conditions(range(0,100)) ->execute(); This lines do not work for me..
1
vote
2answers
67 views

How to subtract two columns with db_select()?

I have a db_select query that outputs two columns. I want to find the difference between these columns, output to another column, and then put a condition on this third column. Here is a mysql query ...
1
vote
1answer
22 views

Why this code cannot delete the rows that i want?

i want keep the 100 rows that has the biggest timestamp and delete all the other rows... Here follow the code that i have create : $values_to_delete = db_delete('table1', 't'); ...
1
vote
1answer
368 views

These lines of code gets me out this error and i cannot understand it

$number_to_keep = db_select('variable', 'va') ->fields('va.value') ->condition('va.name', 'dblog_row_limit', '=') ->execute(); And it gets me out that errors: Notice: Undefined ...
1
vote
0answers
49 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
0answers
14 views

filter out values that are not in both tables [closed]

I would like to get the values that are not present in both tables. Table A ID Name 1 A 2 B 3 C Table B ID Name 4 F 5 G 1 A I would like to 2 B 3 C 4 F 5 G What I have tried so ...
0
votes
1answer
34 views

Some errors when I save my content

I have some errors when I try to validate my content, I add a lot a modules at the same time, and I don't know witch module causes this error. I uninstalled some of them without success, Is it some ...
1
vote
0answers
29 views

Drupal 7 Dyanamic Query with CONCAT [closed]

Can someone please tell me the correct drupal 7 dynamic query syntax to use in place of the following line? LEFT JOIN {url_alias} AS ua ON CONCAT('node/', nid)=source I tried the following (with no ...
1
vote
0answers
36 views

Converting static SQL query to dynamic

I've created my first dynamic, OO, SQL query in Drupal 7 and I'd like feedback. I have a static query (below) that works. I'm trying to create a dynamic query so I can use the 'pager' extension. This ...
1
vote
0answers
44 views

Architecture/General Question about implementing feature [closed]

I have a content type in my site and the content is created from a csv feed. I want to create another content type with a node reference for the first content which will have the result of some ...
0
votes
2answers
72 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
0answers
19 views

How to transparently switch databases for queries

I need to write some modules that need data from external, non-Drupal db's. These db's can't be integrated for security reasons. However, the current code I have is littered with db_set_active ...
1
vote
0answers
32 views

Add record drupal_write_record

I am editing the push_notifications module to use it for multi app. In the database I added a field "appname" in the push_notifications_tokens table. In the code everything is working except the post ...
0
votes
2answers
56 views

Entityfieldquery with two field conditions for the same field

I need to make a query where the same filed must have one value OR another. Basically: ->fieldCondition($field_example, 'tid', (array) $var1) ... OR ->fieldCondition($field_example, 'tid', ...
0
votes
1answer
27 views

Static vs. Dynamic Queries in Drupal 7 and the Right Syntax to Use [closed]

Does anyone know of a good tutorial that explains, not with just one example of an easy query, how to create complex select queries in Drupal 7 that uses the preferred method of query writing? I've ...
0
votes
1answer
49 views

db_update query does not work properly

I work with views bulk operations and I wanna change status of selected items in a view. I applied db_update query, but something went wrong. I was debugging my code following: ...
0
votes
1answer
32 views

Custom views query - pager dosn't work

I am trying to modify view query, basically I build my custom query and assigned it to: $view->build_info['query'] = $query; $view->build_info['count_query'] = $query; everything has been ...
0
votes
0answers
30 views

Returning multiple images in SQL query

I have two images I need to return in my custom module's SQL. It works with returning just 1, but when I add another it shows both as blank and dpm($row) shows the field as NULL. I've double checked ...
0
votes
0answers
13 views

Adding a Pager to 3 Queries on a Custom Module

I have a multi-page form module that, when submitted, queries the database with some complex logic. Overall it's working fine. However, all the results are displayed on ONE giant page. I'd like the ...
1
vote
1answer
62 views

db_update after a submit button is clicked

I want to update a "picture" field with a type of character varying, after a button is click. My customize module is already connected to it's database. This is my form: function ...
1
vote
0answers
19 views

Is db_next_id() thread safe?

My problem: Say, I need to run a massive amount of inserts into two related tables: Table1: id1, data1 Table2: id1 (foreign key), id2, data2. I want my code to work fast, so I can't run a loop like ...
0
votes
1answer
102 views

db_query gives PDO Exception “General error: 1366 Incorrect integer value:” when I try to update table

I'm trying to execute the following SQL query $tweet_id_int = intval($tweet->id); $result = db_query("INSERT INTO tweetsDB (handle,tweet,time_string,tweetid) VALUES ...
0
votes
1answer
44 views

How to map url_alias table to node table?

I was trying to use some SQL to map the url_alias field to my node field on the url_alias.pid = node.nid field. However, it turns out that these are not apparently related, sometimes they are the same ...
2
votes
2answers
128 views

Using orderBy correctly with hook_query_alter

I have a hook_query_alter function that I'm using to edit my search.module results. It works ok so far. However, I'm having trouble adding an orderBy condition that I need. Here's the SQL I want added ...
0
votes
0answers
32 views

Concat query used in a like condition

I'd like to perform a query where I get the value of various fields(stored in different tables) and check if a string exists on them. This is part of a bigger query. What I did until know is : ...
0
votes
0answers
35 views

load site on to different server

I want to move my drupal site onto another server. I installed drupal using drush & copied the sites/ directory to where its suppposed to go. I then copied the database and changed credentials in ...
0
votes
1answer
26 views

settings and switching to external pgsql db

I am working with Drupal 7.3.4 and attempting to follow the instructions of changing settings.php so that I can switch to a pgsql DB within a module and then switch back to the default mysql after ...
1
vote
1answer
62 views

db_update without table prefix on custom table

I installed Drupal with table prefixes in the database. I have my own tables in the same database which I am trying to update. I am getting an error because Drupal is automatically adding the prefix ...