| 7 database.inc | public DatabaseStatementInterface::rowCount() |
| 8 database.inc | public DatabaseStatementInterface::rowCount() |
Returns the number of rows affected by the last SQL statement.
Return value
The number of rows affected by the last DELETE, INSERT, or UPDATE statement executed.
File
- includes/
database/ database.inc, line 1955 - Core systems for the database layer.
Code
<?php
public function rowCount();
?> Login or register to post comments
Comments
Usage example
Here is an example of how to use it in the context of counting the number of sub-entries for the entries of a specific 'main_menu' into a loop variable called $num (although it might be obvious for some, I'm sure this will save a few seconds to many):
$query = db_select('menu_links', 'menu');$query->fields('menu')->condition('menu_name','main_menu')->condition('plid',0,'=');
$result = $query->execute;
while ($record = $result->fetchAssoc()) {
$plid = $record['mlid'];
$query_sub = db_select('menu_links', 'menu');
$query_sub->fields('menu')->condition('menu_name', 'main_menu')->condition('plid', $plid);
$result_sub = $query_sub->execute();
$num = $result_sub->rowCount();
}