Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3481946
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:30:13+00:00 2026-05-18T10:30:13+00:00

I am using db_placeholder within a query to replace an array of strings. $paths

  • 0

I am using db_placeholder within a query to replace an array of strings.

$paths = array("commentary_analysis/18", "commentary_analysis/16", "commentary_analysis/95", "commentary_analysis/89");

$query = "SELECT DISTINCT a.uid, u.mail FROM {alerts} a JOIN {users} u on u.uid = a.uid WHERE u.mail IS NOT NULL AND u.mail != '' AND u.status = 1 AND a.status = %d AND a.view_path IN (" . db_placeholders($paths, 'text') . ") ORDER BY a.uid ASC";

$users_to_notify = db_query($query, $alert_status, $paths);

The query is not returning results, when I know it should. I debugged the query to see the exact query that is getting run. The query being run is,

SELECT DISTINCT a.uid, u.mail FROM alerts a JOIN users u on u.uid = a.uid WHERE u.mail IS NOT NULL AND u.mail != '' AND u.status = 1 AND a.status = 1 AND a.view_path IN ('','','','') ORDER BY a.uid ASC

Notice, a.view_path IN ('','','',''). That is the problem. From what I can see, I expect that db_placeholder is getting used with the correct syntax.

Could someone tell me why my use of db_placeholder is returning ('','','','') instead of ("commentary_analysis/18", "commentary_analysis/16", "commentary_analysis/95", "commentary_analysis/89")?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:30:13+00:00Added an answer on May 18, 2026 at 10:30 am

    The problem is you can either pass all single value arguments to db_query, or you can pass an array of arguments. Your code is passing a single value, and then an array, and Drupal just isn’t that flexible.

    Try this:

    $paths = array(
      'commentary_analysis/18',
      'commentary_analysis/16',
      'commentary_analysis/95',
      'commentary_analysis/89',
    );
    
    $query = "SELECT DISTINCT a.uid, u.mail
              FROM {alerts} a
              JOIN {users} u on u.uid = a.uid
              WHERE u.mail IS NOT NULL
                AND u.mail != ''
                AND u.status = 1
                AND a.status = %d
                AND a.view_path IN (" . db_placeholders($paths, 'varchar') . ")
              ORDER BY a.uid ASC";
    
    $args = array_merge(array($alert_status), $paths);
    $users_to_notify = db_query($query, $args);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fetch some records from MSSQL DB using EntityObject with EntitySQL query.
I am trying to write a select query from one single table in SQLite
Is there a way to execute a query(containing built in DB function) using PreparedStatement?
Using LINQ to SQL db.Products.Where(c => c.ID == 1).Skip(1).Take(1).ToList(); executes SELECT [t1].[ID], [t1].[CategoryID], [t1].[Name],
I am using Zend_Db with the Pdo_Mysql driver. This query does not give any
I've got a class that creates a list from a DB using SimpleCursorAdapter. I
I am attempting to pull some information from my tnsnames file using regex. I
Using a DB with C++ is a real mess and it was refreshing when
I want to connect to DB using the iSeries Client Access driver. I use
I am interacting with an Oracle DB using SQL over an ODBC connection. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.