Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More robust checking of returned $rs

  • Loading branch information...
commit e53b0823ab2127c256b7474a37c36d0cc65c14bb 1 parent 8663bfd
moodler authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/datalib.php
View
12 lib/datalib.php
@@ -92,7 +92,7 @@ function record_exists_sql($sql) {
global $db;
$rs = $db->Execute($sql);
- if (!$rs) return false;
+ if (empty($rs)) return false;
if ( $rs->RecordCount() ) {
return true;
@@ -142,7 +142,7 @@ function count_records_sql($sql) {
global $db;
$rs = $db->Execute("$sql");
- if (!$rs) return 0;
+ if (empty($rs)) return 0;
return $rs->fields[0];
}
@@ -171,7 +171,7 @@ function get_record_sql($sql) {
global $db;
$rs = $db->Execute("$sql");
- if (!$rs) return false;
+ if (empty($rs)) return false;
if ( $rs->RecordCount() == 1 ) {
return (object)$rs->fields;
@@ -267,7 +267,7 @@ function get_records_sql($sql) {
global $db;
$rs = $db->Execute("$sql");
- if (!$rs) return false;
+ if (empty($rs)) return false;
if ( $rs->RecordCount() > 0 ) {
if ($records = $rs->GetAssoc(true)) {
@@ -333,7 +333,7 @@ function get_records_sql_menu($sql) {
global $db;
$rs = $db->Execute("$sql");
- if (!$rs) return false;
+ if (empty($rs)) return false;
if ( $rs->RecordCount() > 0 ) {
while (!$rs->EOF) {
@@ -353,7 +353,7 @@ function get_field($table, $return, $field, $value) {
global $db, $CFG;
$rs = $db->Execute("SELECT $return FROM $CFG->prefix$table WHERE $field = '$value'");
- if (!$rs) return false;
+ if (empty($rs)) return false;
if ( $rs->RecordCount() == 1 ) {
return $rs->fields["$return"];
Please sign in to comment.
Something went wrong with that request. Please try again.