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 8559881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:09:19+00:00 2026-06-11T16:09:19+00:00

Well, the weakest point of PDO is inability to debug it because prepared statements

  • 0

Well, the weakest point of PDO is inability to debug it because prepared statements are actually stored on a server side. I spent the whole day around the problem that I cannot understand at all. So, here is the case:

//the query itself
            //Did other customers from the list buy the same style in last 3 months?
            $end = date("Y-m-d H:i:s");
            $start = strtotime("-3 month", strtotime($end));
            $start = date('Y-m-d 00:00:00', $start);
            $q = $db->prepare('SELECT COUNT(*) as totals FROM web_order
                            JOIN web_order_item ON web_order_item.od_id = web_order.od_id
                            WHERE web_order.p_vendor IN (:id)
                            AND od_pcode = :pcode
                            AND od_date BETWEEN :start AND :end
                            ');
            $q->bindValue(":pcode", '1008GD');
            $q->bindValue(":id", $custList);
            $q->bindValue(":start", $start);
            $q->bindValue(":end", $end);
            $q->execute();
            echo "SELECT COUNT(*) as totals FROM web_order
                            JOIN web_order_item ON web_order_item.od_id = web_order.od_id
                            WHERE web_order.p_vendor IN ($custList)
                            AND od_pcode = '1008GD'
                            AND od_date BETWEEN '$start' AND '$end'";
            $res = $q->fetchAll();
die(print_r($res));

And here comes the funny bit – print_r($res) prints the empty array.

Array ( [0] => Array ( [totals] => 0 [0] => 0 ) )

While echo statement with exactly the same query prints

SELECT COUNT(*) as totals FROM web_order JOIN web_order_item ON web_order_item.od_id = web_order.od_id WHERE web_order.p_vendor IN ('210','1107','2295','2452') AND od_pcode = '1008GD' AND od_date BETWEEN '2012-06-13 00:00:00' AND '2012-09-13 13:15:36'

If I execute the echoed query by itself I get ‘totals’ column to have a value of 1. At the same moment PDO statement returns nothing.

Any help will be appreciated.

UPDATE:
Although the answer was posted, I still do not get why this did not work. $custList is actually a string, not an array, because I used

$custList = implode(",", $custList);
  • 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-06-11T16:09:20+00:00Added an answer on June 11, 2026 at 4:09 pm

    As Ken mentioned in the comments on your question, your problem is the :id binding, namely, that PDO doesn’t allow you to bind an array as a param. You’ll need to loop through the array and bind the individual elements into the query.

    Generally, I handle this with a foreach loop that adds a ? to the query for each element of the array, then I bind each of the elements into the query in the correct order with the other prepared variables (since ? is positional, instead of named).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I just started to work on server side scripting , I chose PHP,
Well im here because i have a problem. i have code that was created
Well, that might be a strange question, and maybe just because I'm not familiar
Well, I want to have a redirect script on my server. I want it
Well the title of this question might not actually reflect what I want, I
Well, it may actually be a simple case but I'm having a tough time
Well i'm actually working on a Memory Injector. What i'm actually trying to do
Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
Well I can start the thread when I press togglebutton to ON and it
well i have a configuration like this in the components part of my config

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.