Commit df2c0337 authored by Dries's avatar Dries

- Patch 6066 by Adrian: PostgreSQL does not return 'affected rows' when doing
  a select statement.  Even though PEAR supports this functionality, it fails
  silently when using PostgreSQL.  We use the db_num_rows() function instead
  to return the amount of rows returned.  (According to Killes, the MySQL
  manual also states that it should not return affected rows on a 'select'
  statement.)
parent f54aab6a
......@@ -1491,7 +1491,7 @@ function node_delete($edit) {
function node_page_default() {
$result = pager_query('SELECT nid, type FROM {node} WHERE promote = 1 AND status = 1 ORDER BY static DESC, created DESC', variable_get('default_nodes_main', 10));
if (db_affected_rows($result)) {
if (db_num_rows($result)) {
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed') .'" />');
$output = '';
......
......@@ -1491,7 +1491,7 @@ function node_delete($edit) {
function node_page_default() {
$result = pager_query('SELECT nid, type FROM {node} WHERE promote = 1 AND status = 1 ORDER BY static DESC, created DESC', variable_get('default_nodes_main', 10));
if (db_affected_rows($result)) {
if (db_num_rows($result)) {
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed') .'" />');
$output = '';
......
......@@ -391,7 +391,7 @@ function user_block($op = "list", $delta = 0) {
/* perform database queries to gather online user lists */
$guests = db_fetch_object(db_query("SELECT COUNT(DISTINCT sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0", time() - $time_period));
$users = db_query("SELECT DISTINCT uid, MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 GROUP BY uid ORDER BY max_timestamp DESC", time() - $time_period );
$total_users = db_affected_rows();
$total_users = db_num_rows($users);
/* format the output with proper grammar */
if ($total_users == 1 && $guests->count == 1) {
......
......@@ -391,7 +391,7 @@ function user_block($op = "list", $delta = 0) {
/* perform database queries to gather online user lists */
$guests = db_fetch_object(db_query("SELECT COUNT(DISTINCT sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0", time() - $time_period));
$users = db_query("SELECT DISTINCT uid, MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 GROUP BY uid ORDER BY max_timestamp DESC", time() - $time_period );
$total_users = db_affected_rows();
$total_users = db_num_rows($users);
/* format the output with proper grammar */
if ($total_users == 1 && $guests->count == 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment