Topics related to the database API implemented by Drupal.

learn more… | top users | synonyms (1)

0
votes
1answer
10 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
23 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
22 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
35 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
25 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
21 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
17 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
29 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
81 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? ...
1
vote
2answers
71 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
55 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
28 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
46 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
49 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
364 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
42 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
28 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
22 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
29 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
43 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
53 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
48 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
22 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
44 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
31 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
27 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
60 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
18 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
84 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
38 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
126 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
27 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
34 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
25 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
47 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 ...
0
votes
1answer
47 views

how using mysql CAST in db_select

I want to try doing Mysql Casting in my query by db_select but face to error, $q=db_select('node','n'); $q->join('field_data_field_cinema_type', 'fct', 'fct.entity_id = n.nid'); ...
0
votes
1answer
21 views

Using Left() with Drupal Custom Module

I'm trying to return only the first 200 characters (if there are more than that) from a body field in a Drupal custom module. I've found the general php/mysql solution here: ...
0
votes
1answer
21 views

“contact” SQL table: what is it for and where do I edit it?

We are running a site with the Hotel Diamond theme. Today we received a bounced email: apparently, someone had tried using the contact form in the site to send us a message, and the system had tried ...
0
votes
3answers
103 views

Can't access admin after moving localhost to live server

Almost finished my site and thought I have completed the puzzle but there is one last frontier in my way and a rather annoying ankle-biter... I moved my site off my localhost onto my live server ...
0
votes
1answer
41 views

How can I concatenate string in where clause?

I'm trying to execute the following query but when I append the 'n.nid = "node/" + ua.source' condition I'm getting an error page. could you please kindly help me on this? or suggest me an ...
0
votes
0answers
7 views

addExpression() and FROM_UNIXTIME format [duplicate]

Having some trouble figuring this out, all of the examples I have looked at make it appear that what I have done is correct. Here is my query: $query = db_select('webform_submissions', 'w'); ...
0
votes
0answers
7 views

Can't edit/add a specific content type sometimes - SQL has gone away [duplicate]

Hi Can anyone help with this situation. I am on Drupal 7.12 and I am getting a white page (or if I have enabled errors to show, a SQL has gone away error when I try to add or edit a specific content ...
0
votes
1answer
53 views

SelectQuery row_number won't work with PDO

I'm working on a project that needs to query a MySQL database and select the row number (among other columns) for each row. To be more specific, I have the table test and want to get the table result: ...
1
vote
4answers
99 views

Does node_delete() function deletes the attached media files as well?

I'm deleting my 'articles' created before Sat Nov 1 00:00:00 2014 GMT from Drupal 7.34 site, but I'm not sure whether the node_delete() delete the media files as well? Below is my processing code: ...