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

  • Home
  • SEARCH
  • 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 521019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:12:22+00:00 2026-05-13T08:12:22+00:00

Okay, so I have been using a PDO wrapper for a project I’m working

  • 0

Okay, so I have been using a PDO wrapper for a project I’m working on, and I’m trying to find out whether a DELETE query was successful or not. Here is the code I am using:

/**
* A pretty straight-forward query to delete a row from the verification
* table where user_id is $user_id and code is $code
*/
$result = $this->database->query("DELETE FROM verification " .
                                 "WHERE user_id = %u AND code = %s",
                                 $user_id,
                                 $code);

/**
 * This function will grab the PDO's exec() return, which should
 * return the number of rows modified.
 */
if($this->database->getNumAffected($result) > 0)
    return true;
else
    return false;

The problem is, whether the DELETE query actually deletes a row or not, $this->database->getNumAffected($result) always returns ‘0’.

You can check out the wrapper, but basically $this->database->getNumAffected($result) simply returns exactly the same value PDO::exec() would return.

I tried this code without the wrapper (directly into PDO,) and I had the same problem but reverse: it always returned ‘1’ (whether a row was deleted or not.)

Any help would be greatly appreciated.

EDIT: Based on this SO question, I’m doing everything right… I don’t understand why this isn’t working.

  • 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-13T08:12:23+00:00Added an answer on May 13, 2026 at 8:12 am

    It doesn’t work as you expect because the ‘wrapper’ that you’re using doesn’t ever use PDO::exec() – it wraps everything in a PDO statement. According to a quick read of the source code for version 2.2.6 of the ‘database’ class from the URL you provided, the ‘query’ method should return an array which contains the statement handle:

    502 $statement = $this -> getDatabaseConnection () -> prepare ( $query );
    ...
    587 $ret = array ( $statement, func_get_args (), $lastIndex );
    588     
    589 return ( $ret );
    

    So, assuming your $this->database->query() is calling this database class’ query method, you should be able to do $result[0]->rowCount().

    Note that your assertion to the earlier response that “the wrapper that [you are] using uses a different version of rowCount() because of an error that exists with the rowCount() function” is not true – the wrapper implements a numRows, but this is not the same thing as PDOStatement::rowCount(), which is intact inside of the statement handle returned from database::query().

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

Sidebar

Ask A Question

Stats

  • Questions 283k
  • Answers 283k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Django generally has very good Unicode support (see the Django… May 13, 2026 at 4:16 pm
  • Editorial Team
    Editorial Team added an answer You should use Mutex class, like explained here: Best way… May 13, 2026 at 4:16 pm
  • Editorial Team
    Editorial Team added an answer First preDispatch() is called for instances of Zend_Controller_Plugin_Abstract. Here you… May 13, 2026 at 4:16 pm

Related Questions

I have a process that's going to initially generate 3-4 million PDF files, and
My question follows on from the answer in How to create a button with
Let me start off by saying Im VERY new to iphone development, but Im
Okay so I have been trying to get into IoC lately. However, I keep
Okay, so I've created a custom template for Joomla, and gotten that working. However,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.