Orderby and desc optional fields added to search criteria (#589).
This commit is contained in:
parent
db8965390d
commit
44cc15875b
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.33 $
|
Version : $Revision: 1.34 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -52,7 +52,7 @@ require_once "Transport.php";
|
||||||
* Core of LiveSupport file storage module
|
* Core of LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.33 $
|
* @version $Revision: 1.34 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class BasicStor extends Alib{
|
class BasicStor extends Alib{
|
||||||
|
@ -665,6 +665,8 @@ class BasicStor extends Alib{
|
||||||
* (may be empty or ommited only with less then 2 items in
|
* (may be empty or ommited only with less then 2 items in
|
||||||
* "conditions" field)
|
* "conditions" field)
|
||||||
* </li>
|
* </li>
|
||||||
|
* <li>orderby : string - metadata category for sorting (optional)</li>
|
||||||
|
* <li>desc : boolean - flag for descending order (optional)</li>
|
||||||
* <li>conditions - array of hashes with structure:
|
* <li>conditions - array of hashes with structure:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>cat - string, metadata category name</li>
|
* <li>cat - string, metadata category name</li>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.5 $
|
Version : $Revision: 1.6 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/DataEngine.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/DataEngine.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -44,6 +44,8 @@ require_once "XML/Util.php";
|
||||||
* (may be empty or ommited only with less then 2 items in
|
* (may be empty or ommited only with less then 2 items in
|
||||||
* "conditions" field)
|
* "conditions" field)
|
||||||
* </li>
|
* </li>
|
||||||
|
* <li>orderby : string - metadata category for sorting (optional)</li>
|
||||||
|
* <li>desc : boolean - flag for descending order (optional)</li>
|
||||||
* <li>conditions - array of hashes with structure:
|
* <li>conditions - array of hashes with structure:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>cat - string, metadata category name</li>
|
* <li>cat - string, metadata category name</li>
|
||||||
|
@ -273,10 +275,19 @@ class DataEngine{
|
||||||
{
|
{
|
||||||
$filetype = $this->filetypes[strtolower($criteria['filetype'])];
|
$filetype = $this->filetypes[strtolower($criteria['filetype'])];
|
||||||
$operator = strtolower($criteria['operator']);
|
$operator = strtolower($criteria['operator']);
|
||||||
|
$desc = $criteria['desc'];
|
||||||
$whereArr = $this->_makeWhereArr($criteria['conditions']);
|
$whereArr = $this->_makeWhereArr($criteria['conditions']);
|
||||||
|
$orderbyQn = strtolower($criteria['orderby']);
|
||||||
|
$obSplitQn = XML_Util::splitQualifiedName($orderbyQn);
|
||||||
|
$obNs = $obSplitQn['namespace'];
|
||||||
|
$orderby = $obSplitQn['localPart'];
|
||||||
$browse = !is_null($brFld);
|
$browse = !is_null($brFld);
|
||||||
if(!$browse){
|
if(!$browse){
|
||||||
$fldsPart = "DISTINCT to_hex(f.gunid)as gunid";
|
if(!$orderby){
|
||||||
|
$fldsPart = "DISTINCT to_hex(f.gunid)as gunid";
|
||||||
|
}else{
|
||||||
|
$fldsPart = "DISTINCT f.gunid";
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$fldsPart = "DISTINCT br.object";
|
$fldsPart = "DISTINCT br.object";
|
||||||
}
|
}
|
||||||
|
@ -291,7 +302,16 @@ class DataEngine{
|
||||||
$sql = $this->_makeOrSql(
|
$sql = $this->_makeOrSql(
|
||||||
$fldsPart, $whereArr, $fileCond, $browse, $brFldNs, $brFld);
|
$fldsPart, $whereArr, $fileCond, $browse, $brFldNs, $brFld);
|
||||||
}
|
}
|
||||||
// echo "\n---\n$sql\n---\n";
|
if(!$browse && $orderby){
|
||||||
|
$sql =
|
||||||
|
"SELECT to_hex(sq2.gunid)as gunid, m.object\n".
|
||||||
|
"FROM (\n$sql\n)sq2\n".
|
||||||
|
"LEFT JOIN ls_mdata m\n".
|
||||||
|
" ON m.gunid = sq2.gunid AND m.predicate='$orderby' AND m.objns='_L'".
|
||||||
|
(!is_null($obNs)? " AND m.predns='$obNs'":'')."\n".
|
||||||
|
"ORDER BY m.object".($desc? ' DESC':'')."\n";
|
||||||
|
}
|
||||||
|
echo "\n---\n$sql\n---\n";
|
||||||
$cnt = $this->_getNumRows($sql);
|
$cnt = $this->_getNumRows($sql);
|
||||||
if(PEAR::isError($cnt)) return $cnt;
|
if(PEAR::isError($cnt)) return $cnt;
|
||||||
$res = $this->dbc->getCol($sql.$limitPart);
|
$res = $this->dbc->getCol($sql.$limitPart);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.40 $
|
Version : $Revision: 1.41 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -35,7 +35,7 @@ require_once "BasicStor.php";
|
||||||
* LiveSupport file storage module
|
* LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.40 $
|
* @version $Revision: 1.41 $
|
||||||
* @see BasicStor
|
* @see BasicStor
|
||||||
*/
|
*/
|
||||||
class GreenBox extends BasicStor{
|
class GreenBox extends BasicStor{
|
||||||
|
@ -344,6 +344,8 @@ class GreenBox extends BasicStor{
|
||||||
* </li>
|
* </li>
|
||||||
* <li>limit : int - limit for result arrays (0 means unlimited)</li>
|
* <li>limit : int - limit for result arrays (0 means unlimited)</li>
|
||||||
* <li>offset : int - starting point (0 means without offset)</li>
|
* <li>offset : int - starting point (0 means without offset)</li>
|
||||||
|
* <li>orderby : string - metadata category for sorting (optional)</li>
|
||||||
|
* <li>desc : boolean - flag for descending order (optional)</li>
|
||||||
* <li>conditions - array of hashes with structure:
|
* <li>conditions - array of hashes with structure:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>cat - string, metadata category name</li>
|
* <li>cat - string, metadata category name</li>
|
||||||
|
|
Loading…
Reference in New Issue