CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Affected rows function?
Pages: [1]

Author Topic: Affected rows function?  (Read 2075 times)

barrylb

  • I’m new here
  • *
  • Posts: 19
  • Karma: 3
Affected rows function?
March 05, 2009, 07:52:33 pm
Quick question for someone... I'm using code like
Code: [Select]
CRM_Core_DAO::executeQuery("UPDATE mytable SET ...") to do some database queries.  How can I access a function to return number of affected rows like mysql_affected_rows()  ?
It looks to be in the code ... maybe a function called affectedRows() ... but I can't figure out how to access it.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Affected rows function?
March 05, 2009, 08:46:24 pm

$dao =& CRM_Core_DAO::executeQuery("UPDATE mytable SET ...");

$dao->N

should give you the number of affected rows (i think, do a print_r on $dao to make sure). You can also check the DB_DataObject documentation to see if there is a function for this

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

taram

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
Re: Affected rows function?
March 19, 2009, 01:02:23 pm
Yes $dao->N has the effected number of rows. I have used this in my code.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Affected rows function?

This forum was archived on 2017-11-26.