Menu

#107 drawlib.php incorrect limits on list_drawings

open
nobody
None
5
2012-12-08
2003-12-02
Lee Essen
No

(As of CVS 1-Dec-2003)

The list_drawings routine puts a limit on the result of
a seach based solely on the name, where is really needs
to limit based on a name and max(version) match.

Using this mechanism it's possible to reduce the number
of sql calls and simplify the code quite a bit
(although I'm not sure about the performance profile
for these type of queries).

--- drawlib.php-preFIX 2003-10-25 14:02:35.000000000 +0100
+++ drawlib.php 2003-12-02 11:47:02.000000000 +0000
@@ -100,18 +110,17 @@
} else {
$mid = "";
}
- $query = "select * from `tiki_drawings`
$mid order by ".$this->convert_sortmode($sort_mode);
- $query_cant = "select count(*) from
`tiki_drawings` $mid";
+ // LEE: changed to use distinct so we
get the right page count
+ $query = "select *,max(version) as maxv
from `tiki_drawings` $mid group by `name` order by
".$this->convert_sortmode($sort_mode);
+ $query_cant = "select
count(distinct(name)) from `tiki_drawings` $mid";
$result =
$this->query($query,$bindvars,$maxRecords,$offset);
$cant =
$this->getOne($query_cant,$bindvars);
$ret = array();

while ($res = $result->fetchRow()) {
- $last_version =
$this->getOne("select max(`version`) from
`tiki_drawings` where `name`=?",array($res['name']));
- if ($res['version'] ==
$last_version) {
- $res['versions'] =
$this->getOne("select count(*) from `tiki_drawings`
where `name`=?",array($res['name']));
- $ret[] = $res;
- }
+ $res['version'] = $res["maxv"];
+ $res['versions'] =
$this->getOne("select count(*) from `tiki_drawings`
where `name`=?",array($res['name']));
+ $ret[] = $res;
}
$retval = array();
$retval["data"] = $ret;

Discussion


Log in to post a comment.