ctsql_affected_rows
Returns the number of affected rows from the previous c-treePHP operation.
Declaration
int ctsql_affected_rows ( [resource connectionID])
Description
ctsql_affected_rows() returns the number of rows affected by the last INSERT, UPDATE or DELETE query. This will also work with the SELECT statement but only after fetching the rows.
Returns
ctsql_affected_rows() returns the number of rows affected by the last INSERT, UPDATE or DELETE query associated with connectionID.
Example
<?php
/* connect to database */
$link = ctsql_connect('ctreeSQL', 'admin', 'ADMIN');
if (!$link) {
die('Failed to connect to FairCom DB SQL: ' . ctsql_error());
}
/* this should return the correct numbers of deleted records */
ctsql_query('DELETE FROM mytable WHERE age < 50');
printf("Records deleted: %d\n", ctsql_affected_rows());
/* with a where clause that is never true, it should return 0 */
ctsql_query('DELETE FROM mytable WHERE 0');
printf("Records deleted: %d\n", ctsql_affected_rows());
?>
The above example would produce the following output:
Records deleted: 10
Records deleted: 0