#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    146
    Rep Power
    2

    Question PDO equivalent for mysqli_info() ?


    Hi all,

    Is there an equivalent to mysqli_info() for use with PDO Statements?

    Right now, I'm using this to determine if any rows were affected during an UPDATE:
    Code:
    $count = $STMT->rowCount();
    However, in my case, there are two different situations where an UPDATE might return "0" from rowCount(). 1. If a record wasn't found or 2. If a record was found, but an update didn't happen because the column being updated already contained the same information.

    With mysqli_info() I could differentiate between those two "zero rows affected" situations. How can I do this using PDO Statements?

    Thanks.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,926
    Rep Power
    1045
    Hi,

    as far as I can tell, it's either-or. By default, rowCount() will return the number of changed rows. Alternatively, you can set PDO::MYSQL_ATTR_FOUND_ROWS to make the method return the number of found rows instead. But I haven't found a way to get both.

    Note that the differentiation between matched and changed rows seems to be a MySQL quirk. Since PDO is a generalized database extension, it may not support every special feature of every database system. If you want to write your code exclusively for MySQL, then MySQLi is the better choice.

    What do you need this for, by the way?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    146
    Rep Power
    2
    thanks for the reply.

IMN logo majestic logo threadwatch logo seochat tools logo