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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:36:09+00:00 2026-06-06T00:36:09+00:00

From what I know now about PDO statements and my own experiences on localhost

  • 0

From what I know now about PDO statements and my own experiences on localhost and Google – there are some difficulties with using multiple PDO statements in one query. For instance this situation:

$stmt = $db_people->prepare("SELECT * FROM people WHERE online=1");
$stmt->execute();
$results_people = $stmt->fetch(PDO::FETCH_ASSOC);

On this query I can do simple PDO statement like fetch (in example). But when I want to use PDO statement like this:

$rows = $stmt->rowCount();

It is not possible and the statement will not return the right number of rows. When I do it in the other way around and filling one of the column name – rowCount works correctly like this:

$stmt = $db_people->prepare("SELECT name FROM people WHERE online=1");
$stmt->execute();
$rows = $stmt->rowCount();

And adding fetch after that like this:

$results_people = $stmt->fetch(PDO::FETCH_ASSOC);

Will not work corectly in this example. My question is – How to combine two different PDO statements in one single query? Thank you.

  • 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-06T00:36:11+00:00Added an answer on June 6, 2026 at 12:36 am

    The answer probably depends on which operations you’re trying to combine. For instance, if you’re trying to combine PDOStatement::rowCount() with a SELECT SQL operation, then it’s probably worthwhile to take notice of the warnings in the PDOStatement::rowCount() description which says that rowCount() is not 100% reliable for SELECT statements in all databases.

    If the problem you’re trying to solve is specifically limited to counting the result rows of a SELECT, then another approach would be to use PDOStatement::fetchAll() and count the rows in the returned array.

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

Sidebar

Related Questions

From what I know, everything about OpenGL changed since 3.1 and now I can't
I know from reading the assoc. Google group that there is not currently an
Update Ok - I now know where the multiple page loads are coming from!
So, I now know what to save from nightly builds . What about when
From my last question , I now know how to get access to the
I am updating this post with what I think I now know about getting
OK so I now know there is a way to put all my php
I want to know from a technical view if there is any profit of
I have my application with about 15 activities. Now i know one way of
I'm little bit confused with one thing about memory stack. From what I know

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.