Skip to content

Commit

Permalink
Implement a new DBLayer::has_rows() method
Browse files Browse the repository at this point in the history
This can be used in most places where we currently call num_rows(),
which is not (reasonably easily) implementable for (future) SQLite
or PDO adapters.

Refs #1117.
  • Loading branch information
franzliedke committed Jul 23, 2018
1 parent 4b91e90 commit 06a4ad6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/dblayer/mysqli.php
Expand Up @@ -129,6 +129,12 @@ function num_rows($query_id = 0)
}


function has_rows($query_id)
{
return mysqli_num_rows($query_id) > 0;
}


function affected_rows()
{
return ($this->link_id) ? @mysqli_affected_rows($this->link_id) : false;
Expand Down
6 changes: 6 additions & 0 deletions include/dblayer/mysqli_innodb.php
Expand Up @@ -142,6 +142,12 @@ function num_rows($query_id = 0)
}


function has_rows($query_id)
{
return mysqli_num_rows($query_id) > 0;
}


function affected_rows()
{
return ($this->link_id) ? @mysqli_affected_rows($this->link_id) : false;
Expand Down
6 changes: 6 additions & 0 deletions include/dblayer/pgsql.php
Expand Up @@ -159,6 +159,12 @@ function num_rows($query_id = 0)
}


function has_rows($query_id)
{
return pg_num_rows($query_id) > 0;
}


function affected_rows()
{
return ($this->query_result) ? @pg_affected_rows($this->query_result) : false;
Expand Down
6 changes: 6 additions & 0 deletions include/dblayer/sqlite.php
Expand Up @@ -178,6 +178,12 @@ function num_rows($query_id = 0)
}


function has_rows($query_id)
{
return sqlite_num_rows($query_id) > 0;
}


function affected_rows()
{
return ($this->link_id) ? @sqlite_changes($this->link_id) : false;
Expand Down

0 comments on commit 06a4ad6

Please sign in to comment.