New function to calculate rows
This commit is contained in:
parent
d67338a895
commit
9959da5a1c
|
@ -587,6 +587,7 @@ class dba {
|
||||||
// Is mysqlnd installed?
|
// Is mysqlnd installed?
|
||||||
$retval = $stmt->get_result();
|
$retval = $stmt->get_result();
|
||||||
} else {
|
} else {
|
||||||
|
$stmt->store_result();
|
||||||
$retval = $stmt;
|
$retval = $stmt;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -676,7 +677,7 @@ class dba {
|
||||||
if (is_bool($stmt)) {
|
if (is_bool($stmt)) {
|
||||||
$retval = $stmt;
|
$retval = $stmt;
|
||||||
} else {
|
} else {
|
||||||
$retval = is_array(self::fetch($stmt));
|
$retval = (self::rows($stmt) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::close($stmt);
|
self::close($stmt);
|
||||||
|
@ -684,6 +685,24 @@ class dba {
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returnr the number of rows of a statement
|
||||||
|
*
|
||||||
|
* @param object Statement object
|
||||||
|
* @return int Number of rows
|
||||||
|
*/
|
||||||
|
static public function rows($stmt) {
|
||||||
|
switch (self::$dbo->driver) {
|
||||||
|
case 'pdo':
|
||||||
|
return $stmt->rowCount();
|
||||||
|
case 'mysqli':
|
||||||
|
return $stmt->num_rows;
|
||||||
|
case 'mysql':
|
||||||
|
return mysql_num_rows($stmt);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fetch a single row
|
* @brief Fetch a single row
|
||||||
*
|
*
|
||||||
|
@ -726,11 +745,11 @@ class dba {
|
||||||
// We need to get the field names for the array keys
|
// We need to get the field names for the array keys
|
||||||
// It seems that there is no better way to do this.
|
// It seems that there is no better way to do this.
|
||||||
$result = $stmt->result_metadata();
|
$result = $stmt->result_metadata();
|
||||||
|
$fields = $result->fetch_fields();
|
||||||
|
|
||||||
$columns = array();
|
$columns = array();
|
||||||
foreach ($cols_num AS $col) {
|
foreach ($cols_num AS $param => $col) {
|
||||||
$field = $result->fetch_field();
|
$columns[$fields[$param]->name] = $col;
|
||||||
$columns[$field->name] = $col;
|
|
||||||
}
|
}
|
||||||
return $columns;
|
return $columns;
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
|
|
Loading…
Reference in a new issue