Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    http://us2.php.net/pg_affected_rows

    That function gets the number of rows affected by an INSERT, UPDATE, etc. The problem is that it takes a resource handle as its argument, and the API functions like [phpfunction]pg_update[/phpfunction] don't return handles, but instead just success, failure, or a query to execute.

    So, without running the query manually or building it with the PGSQL_DML_STRING option, any ideas on how to get the number of rows (if any) that were affected by a pg_update or pg_insert?
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Worth trying is passing the connection resource directly to see if perhaps you can get it on a per-connection basis. I somehow doubt that will be the case, however. Why the restrictions you set?

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    I figure that using the dedicated API function is safer, more reliable, and faster than manually running queries...despite the total lack of documentation for the functions, they've been in PHP for at least a year.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Makes sense, but it looks like those functions are PHP-specific, so I would guess that PHP is, in the background, just doing the same thing you would. It's definitely more convenient to pass in an array than to hand-construct a query, though :-)

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    I thought it would be calling the PostgreSQL C API wrappers which is what most of the MySQL API in PHP does.

    I am using pg_query_params, though, never pg_query. An unnamed-but-obvious project that this is being used in, therefore, is effectively immunute to SQL injection.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yeah, I figured it would, too. But it doesn't *look* like there's an equivalent in libpq. There might be one I didn't find, but a quick look didn't reveal anything.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:19 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com