Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
01d21601
Commit
01d21601
authored
Dec 06, 2004
by
Steven Wittens
Browse files
Pager_query's count query was broken if no query arguments were given.
parent
c9cbf291
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/pager.inc
View file @
01d21601
...
...
@@ -60,20 +60,21 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
$args
=
$args
[
0
];
}
// Co
unt the total number of records in this query
.
// Co
nstruct a count query if none was given
.
if
(
!
isset
(
$count_query
))
{
$count_query
=
preg_replace
(
array
(
'/SELECT.*?FROM/As'
,
'/ORDER BY .*/'
),
array
(
'SELECT COUNT(*) FROM'
,
''
),
$query
);
}
$pager_total
[
$element
]
=
db_result
(
db_query
(
$count_query
,
$args
));
// Convert comma-separated $from to an array, used by other functions.
$pager_from_array
=
explode
(
','
,
$from
);
if
(
count
(
$args
))
{
return
db_query_range
(
$query
,
$args
,
(
int
)
$pager_from_array
[
$element
],
(
int
)
$limit
);
}
else
{
return
db_query_range
(
$query
,
(
int
)
$pager_from_array
[
$element
],
(
int
)
$limit
);
if
(
count
(
$args
))
{
$pager_total
[
$element
]
=
db_result
(
db_query
(
$count_query
,
$args
));
return
db_query_range
(
$query
,
$args
,
(
int
)
$pager_from_array
[
$element
],
(
int
)
$limit
);
}
else
{
$pager_total
[
$element
]
=
db_result
(
db_query
(
$count_query
));
return
db_query_range
(
$query
,
(
int
)
$pager_from_array
[
$element
],
(
int
)
$limit
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment