Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 | 



cubrid_affected_rows

Description

The cubrid_affected_rows function gets the number of rows that have been affected by the SQL statements (INSERT, DELETE, and UPDATE).

Syntax

int cubrid_affected_rows([ resource $req_identifier ])

  • req_identifier : Request identifier. If the request identifier is not specified, the last request is assumed.
Return Value
  • Success : Returns the number of rows affected by the SQL statement.
  • When last SQL statement is not INSERT, UPDATE or DELETE : -1
  • When request identifier is not specified and there is no last request : FALSE
Example

<?php

$conn = cubrid_connect("localhost", 33000, "demodb");

 

@cubrid_execute($conn, "DROP TABLE cubrid_test");

cubrid_execute($conn, "CREATE TABLE cubrid_test (t varchar)");

 

for ($i = 0; $i < 5; $i++) {

    cubrid_execute($conn, "INSERT INTO cubrid_test(t) VALUES('cubrid_test')");

}

 

cubrid_execute($conn, "DELETE FROM cubrid_test");

 

$affected_num = cubrid_affected_rows();

var_dump($affected_num);

 

cubrid_disconnect($conn);

?>

 

The above example will output:

 

int(5)

See Also