Topics related to the database API implemented by Drupal.

learn more… | top users | synonyms (1)

1
vote
1answer
21 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
29 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
12 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
342 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
21 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
11 views

filter out values that are not in both tables

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
19 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
10 views

Drupal 7 Dyanamic Query with CONCAT

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
21 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
40 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
22 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
14 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
30 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
39 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
15 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
27 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
21 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
41 views

Save details of form to database table in drupal 7

I'm new to Drupal. I'm fetching ids and title from a database table as key-value pairs and adding them to a drop-down select list. After selecting the respective items in both the lists, I want to ...
0
votes
0answers
19 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
12 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
46 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
16 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
31 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
19 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
112 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
20 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
31 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
17 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
26 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
20 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
18 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
62 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
30 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
34 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
92 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: ...
0
votes
1answer
10 views

How to drop tables shown as Missing in Schema Report

During development/testing after using Backup and Migrate Restore in conjuction with Schema, Schema will show Extra tables no longer referenced in the database, used by modulesetc, and no longer ...
0
votes
1answer
107 views

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'env_id' in 'field list': INSERT INTO {apachesolr_stats}

I get this error a lot in the drupal logs. Several times an hour. Anyone know why, what the impact is, and how to fix it? My config: Acquia Drupal 7.36 Running in IIS 7.5 / Windows Server 2008 ...
0
votes
2answers
16 views

Path to Images for Content Type

In a custom module I'm trying to display results from mysql DB based on items users selected in a form. One of the fields in the content type I'd like to display is an image associated with the node. ...
0
votes
0answers
36 views

Unknown column 'base.i18n_tsid' when using Term Reference Tree module

I've installed Term Reference Tree module to create hierarchical tree to select checkbox and it works fine in English website, but when I am using the same in my Spanish website it gives me following ...
0
votes
1answer
31 views

Does Drupal cache db_query results for multiple users?

I am running into something strange and perhaps someone here can help me. I am trying to prevent two things from happening at once because the second attempt might be influenced by the first attempt. ...
0
votes
2answers
39 views

SQL query for phpMyAdmin to delete authenticated users

Question 1: I would like an sql statement to use in phpMyAdmin to delete the users with the role: authenticated user. Looks like rid = 2. Related Question 2: I show thousands of users in ...
0
votes
2answers
28 views

Adding Placeholders for PHP variables

When creating a query using db_query in my module I want to make sure it's as secure as possible. So I'd like to use placeholders in my 'WHERE' clauses. The problem I'm having is how to use ...
0
votes
0answers
18 views

Add product using Drupal 7 / Ubercart 3 Api

I'm writting my stupid import module and need to programaticaly add products to db. I need to add title, price and link product to existing group; I'v made some research of ubercart api and found ...
0
votes
1answer
27 views

Problems with SQL Syntax using Left Join and OR

I need some help with my SQL. I've got the following code but it's returning multiples of each item and I don't understand why. When I only include the first Left join it returns results as ...
0
votes
3answers
25 views

Correct SQL Statement for Joining Taxonomy Terms

I have 2 different taxonomy vocabularies setup. Courses (First Aid, H2S Alive, Air Monitoring, Gas Detection, etc...) Locations (Vancouver, Calgary, Toronto, Montreal) I have a content type ...
0
votes
1answer
26 views

How to return a DatabaseStatementBase object

I have a method that extends the execute() method used in the Drupal 7 database abstraction layer. When used with db_query, such as: $result = my_extended_db_query("SELECT * FROM {node} WHERE ...