Questions related to SQL queries, used in a module to retrieve information in a database table.

learn more… | top users | synonyms (1)

0
votes
0answers
11 views

How to get recent articles by location?

I have a load of articles and each article is associated with a country using the country codes in the Location module. I need some JSON output that provides the latest 5 articles associated with ...
-1
votes
0answers
10 views

User picture lost, on D6 […/pic.jpg path] to D7 [fid] migration. How to get FID?

Drupal 7 mysql users->picture field is a int(11) fid. Drupal 6 mysql users->picture is a "files/avatars/picture-20.jpg" path. My D6 to D7 port didn't get the fids for my users->picture, they're all ...
0
votes
0answers
26 views

Query to Database

I want make a query for get some products related with the identified user. The type contain has a taxonomy field called 'operating system' and the main profile has also it. For example: If a user has ...
2
votes
0answers
23 views

Extend db query in CKEditor Link User module

The CKEditor Link User module has essentially the functionality I need, but it requires editors to know users by their 'name' field in the users table. I wanted to extend the query to join with the ...
0
votes
0answers
25 views

unknown column base.enabled in 'field list' commerce kickstart entity module?

After moving some modules into my sites/all/modules directory I suddenly get the following error: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.enabled' in 'field ...
1
vote
1answer
42 views

How to Display Unique Values from database using db_select in Drupal

i tried with following code but i cant get the attached output $query = db_select('webform_submitted_data', 'u'); $query->fields('u', array('sid','nid','data')); ...
0
votes
1answer
24 views

drupal 7, db_select(), strange behavior : malformed query

I have a table: mantenimiento_extras. I want a query like this: select * from mantenimiento_extras where id in (7, 9). (this case assumes passing array(7, 9), but it could be variable, even ...
1
vote
0answers
21 views

Why does views add the sort field as a SELECT expression?

The Context I have a content type with a Date field on it, field_dates. The field is configured to have a single value, allow end dates, and also allow recurrences. For those who don't know how ...
0
votes
1answer
39 views

SQL queries in theme functions - is it a bad practise? [closed]

I know, that calling SQL queries in template files is bad practise. But is it bad practise also for theme functions? For example when my form is rendering with my custom theme function: <?php ...
0
votes
3answers
33 views

Limit the results returned by 'published'

I am new to the Database API and SQL queries in general. I needed to create a custom module that could be given a list of fields and would output the average value of each of these fields. I am ...
1
vote
1answer
32 views

PDOException error - Google AdWords Conversion module

My Drupal site is having a serious issue. Whenever I try to add content, such as a Basic Page, I receive this error: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column ...
0
votes
1answer
24 views

Displaying and selecting data from a database in a module

I have a database table (gpx_api) with the following fields: runID userID score distance pace speed gpx_path missionID startTime duration I want to display all of these fields ...
0
votes
2answers
39 views

Lots of generated queries

I enabled devel to Display query log UPDATE: this problem only happens for logged users I found that the Frontpage generate 900 queries. **67** of them generated by the **Locale** module and ...
0
votes
1answer
107 views

hook_views_query_alter all condition

I have an exposed filter that shows products which have multiple entity references. The user should be able to pick some number of entities and the view should show entities containing all those ...
0
votes
1answer
27 views

Help with a db_select() not returning results when it *should*

I'm having trouble figuring out why the db_select() is not returning any results. Long story short, if I pass the results of $results->execute() through a foreach ($results as $result), I don't ...
1
vote
1answer
29 views

What is the difference between havingCondition and having?

Drupal dynamic queries have 2 conditional clauses called having and havingCondition. The documentation states "The Having clause behaves identically to the WHERE clause, except that it uses methods ...
1
vote
1answer
90 views

drupal dynamic query for Inner join on same table

I want a dynamic query to do inner join on same table. My query is "select t1.table1 from table1 t1 inner join table2 t2 on t1.id = t2.id and t1.name = t2.name" I want to join table1 and table2 ...
0
votes
0answers
16 views

set_query_operator not having any effect on my WHERE clause construction

I'm doing a hook_views_query_alter and trying to add a simple OR condition to the end of the existing WHERE clause. I'm using set_group_operator('OR') but when I examine the actual query in the MySQL ...
0
votes
3answers
95 views

programmatically getting custom node belonging to a term

have searched google but cannot find anything specific . Intention is to get all Custom Node types that have been assigned a specific term of vocabulary . for example the follwoing is a db query to ...
3
votes
2answers
124 views

updating field value of a content type with query

I have a problem, may you guys can help me :) I have content type called book, and it has field called stock. Instead of using node_save() I want to update value of book stock using manual query. I ...
0
votes
1answer
68 views

views : display user list with number of comments and forum posts

I want to create blocks to display a list of all users with their number of comments and number of post on forum. In SQL, something like that : SELECT u.name as user, COUNT( n1.nid ) as 'number of ...
1
vote
1answer
55 views

Unable to add WHERE conditions as OR to query object

I'm attempting to override the query method for a node migration in the migrate_d2d module by adding two where conditions with "OR", and the first one is being added as AND instead of OR for some ...
0
votes
1answer
56 views

Manually populating fields using SQL queries

I have created a new field on an existing content type. The field is called "Global News." It's a checkbox and I need it to be checked for all existing nodes. I ran a SQL query to gather all nodes of ...
2
votes
1answer
62 views

How would I use DATEDIFF(), NOW(), and BETWEEN in a db_delete() query?

Is the something like the following possible? db_delete('note_dates') ->condition("DATEDIFF('start', NOW()) BETWEEN 0 AND 30") ->execute();
-1
votes
1answer
40 views

Problem with storing database queries values in array

I have a simple table with four field email,title,url & status status can be '0' or '1' There can be multiple values with status '1'. I want to store the all datas from the table with status ...
2
votes
1answer
50 views

D7 is slow when i visit admin pages

I turned on Devel query log and at the bottom of my pages it shows the log with the number of executed queries and ms. When i visit any admin page for example /admin/appearance i have following ...
3
votes
1answer
56 views

Query between 2 tables

I want the date for the last login for a defined role, but I have a problem with my query with drupal 7. I have the good answer in phpmyadmin with this query : SELECT login FROM `users` AS u, ...
0
votes
1answer
18 views

Error which i am incountering

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dropjob.semaphore' doesn't exist: SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( [:name] => variable_init ) ...
0
votes
1answer
32 views

How can I run a query in the views in the context of the user access?

How can I run a query in the views in the context of the user? E.g. using EntityFieldQuery I can run $query->addMetaData('account', user_load(1)); is there any equivalent for $view->query?
0
votes
2answers
44 views

Module broken by drupal core update (mysql_num_rows)

So I just updated my Drupal core to the latest (6.2.9) because of the many critical security recommendations. I have a module which I built and previously, just before the update I had tested the ...
0
votes
2answers
137 views

How can i limit the drop down list of countries in exposed filter?

I try to use the script https://drupal.org/node/1772498, but I don't get the right db_query for countries in the nodes. I change the script on these line: $result = db_query("SELECT ...
0
votes
0answers
7 views

Track Field Changes: Empty track_field_changes_audit table

I am using the track field changes module to follow changes to one node type. I also currently have a rules link displaying on a different content type node that is supposed to reset this tracker. ...
0
votes
1answer
401 views

Cannot import database. An error occuring in wamp server [closed]

I am using Drupal. I export the sql database from the wamp server and make a new database where I am importing it. It's approx 6 MB. I increase the upload_max_size and clear the cache before ...
0
votes
0answers
18 views

Advantages of dynamic queries over static queries? [duplicate]

Many people suggest me to make use of dynamic queries in Drupal. What is the advantage of using dynamic queries over static queries? Wouldn't it be better to use static queries which directly ...
3
votes
2answers
64 views

Multiple join query

i have a custom module and am using some queries inside, but am not getting the proper output $query = db_select('node', 'N_en')->extend('PagerDefault'); $query->addField('N_en', 'nid', ...
1
vote
1answer
143 views

How to write inner subquery in db_select() method?

How can I write a subquery in drupal 7. My query is the following: SELECT N.nid AS n_nid FROM workflow_node WN LEFT OUTER JOIN node N ON WN.nid = N.tnid WHERE ( WN.sid ...
0
votes
1answer
147 views

How do i check the duplicate entry in the table?

I have created a custom form as below. And the user has to fill all the fields for the submission(I am storing all the fields after submission). Question is how do i check if the email address has ...
0
votes
2answers
87 views

SQL Query to display taxonomy terms

I am working on a Drupal 6 site and have very limited knowledge of writing sql queries. I have a content type manage_current_university (which is a content profile) and in that use a taxonomy cck ...
0
votes
1answer
75 views

Print the query results inside the submit function

I have a query wherein it fetches data from the database, a simple SELECT query which is processed when a certain submit button is clicked. What I want to achieve is to get the results of that query ...
2
votes
1answer
574 views

Add expression db_select

What is the corresponding alternative in Drupal 7 for the following query SELECT row_id,name,email, COUNT(name) AS name_count FROM tn_api_users GROUP BY name HAVING (name_count > 1) Many ...
1
vote
2answers
118 views

Get SQL From View to put in db_query()

I am using views and have a query to return some data. I want to take the SQL from the view and use it in my code. The SQL the view is creating is: SELECT node.title AS node_title FROM {node} node ...
-3
votes
1answer
82 views

copy a site to another installation

Read this documentation https://drupaltraining.stanford.edu/node/111 But I was under the impression the sql database file has to be edited before you can do this? "Before importing SQL file to new ...
2
votes
2answers
93 views

Yo Dawg, I heard you like $view->execute()

I've created a View of all the views that Drupal knows about, whether they reside in code or in the DB. It works great, tells the user about each view, its tags, its displays, its base table, its ...
3
votes
1answer
64 views

How to construct database query with conditions that include 'and' and 'or' clauses?

I am converting a Drupal 6 module to a Drupal 7 module. I have come across the following database query that I don't know how to convert to the new Drupal 7 format. $sql = " SELECT id FROM ...
0
votes
1answer
105 views

Webform component weight within a Fieldset

I am creating a settings page for a specific Webform in version 6.x-3.x which finds all select option components in the form and creates a numeric textfield setting correlating to each select option. ...
1
vote
3answers
329 views

How to go about creating and formatting a custom HTML/PHP table to display SQL data

I am new to drupal and basically I made a database within drupal and filled it with some dummy data. I want create/format/populate a table that looks like on one of my drupal pages: ...
0
votes
1answer
137 views

Update query is not working

In a Drupal 7 custom module, I am updating a record in the database using a form, and I am using the following code to update, but for some reason it is not updating. Can anyone tell me why? I tried ...
1
vote
2answers
45 views

Which of the following is better in terms of performance and speed?

I am creating a view and then using views_get_view_result() function to get the query and print a csv file or Creating a query using db_select and then using it to print the csv. Which of the ...
1
vote
3answers
220 views

Correct way to massively change node author

I want to change all the nodes where $user1 is author and set $user2 as author. I use this PHP Code and it works, but is it the correct way to do it? Or should I use a batch process and load each node ...
0
votes
1answer
33 views

embedding queries

In reading Drupals Building Blocks, in the discussion about optimizing an sql query, it mentions embedding queries. I've read all the pros/cons and for one specific page I have, I would like to ...