ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v6:reference:connection:affected_rows

affected_rows

Syntax
 mixed affected_rows()
Upgrading From V5
V5 Error Condition returns false
V6 Error Condition returns null

Description

The function affected_rows() returns the number of rows affected (add/change/delete) by the last SQL statement executed, or false if the database does not support the function or the statement is not an update. See the driver documentation for support. Most multi-user databases support the command

Because the connection only supports a single global instance of this variable, it is important to retrieve the value of this method before executing another SQL statement (of any type).

Usage

/*
 * connection assumed
 */
$db->execute('DELETE FROM act WHERE actno = 20');
 
print $db->affected_rows();
/*
 * Returns 1
 */
 
$db->execute('SELECT FROM act');
print $db->affected_rows();
/*
 * Returns null
 */
v6/reference/connection/affected_rows.txt · Last modified: by 127.0.0.1