sqlite_num_rows

(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)

sqlite_num_rowsRetorna o número de linhas em um conjunto de resultados.

Descrição

sqlite_num_rows ( resource $result ) : int

Retorna o numero de linhas no conjunto de resultados result.

Nota:

Esta função não pode ser usada com query sem buffer.

Veja também sqlite_changes() e sqlite_query().

add a note add a note

User Contributed Notes 3 notes

up
1
Dylan
5 years ago
//I don't know about you. But for me this is what I had to do

$db = new SQLite3('databasename.db');
$result = $db->query("SELECT * FROM table_name");
$number_of_rows = 0;//for now

while($row = $result->fetchArray()) {
    $number_of_rows += 1;
}

echo "Number of rows: $number_of_rows";
up
-5
be {a} t {dawt} pl
9 years ago
@rezaamya

$db = new SQLite3('databasename.db');
$result = $db->query("SELECT * FROM users");
$rows = count ($result);
echo "Number of rows: $rows";

$rows value should always be 1
... even if the query is invalid
I tested that on
SQLite Library 3.7.7.1
up
-11
rezaamya at gmail dot com
10 years ago
neither of "sqlite_num_rows($result)" and "$result->numRows()" is not working on SQLite3 !
you should use this way:

$db = new SQLite3('databasename.db');
$result = $db->query("SELECT * FROM users");
$rows = count ($result);
echo "Number of rows: $rows";
To Top