getRecordCount DBAPI
- Разработчикам
- DBAPI
- getRecordCount
3170
getRecordCount DBAPI
integer getRecordCount($data_set)
$data_set - соединение с базой
Возвращает количество записей, которое было получено в результате запроса SELECT.
Пример
$output = ''; $result = $modx->db->select('make, model, color, year', 'cars', 'year > 2001'); $total_rows = $modx->db->getRecordCount( $result ); if( $total_rows >= 1 ) { $output .= $total_rows . ' Cars are newer than 2001:
'; while( $row = $modx->db->getRow( $result ) ) { $output .= 'Make: ' . $row['make'] . ' | Model: ' . $row['model'] . ' | Color: ' . $row['color'] . ' | Year: ' . $row['year'] . '
'; } } else { $output = 'There are no cars newer than 2001'; } echo $output;
Источник Функции
Файл: manager/includes/extenders/dbapi.mysql.class.inc.php
Строка: 259
function getRecordCount($ds) { return (is_resource($ds)) ? mysql_num_rows($ds) : 0; }