Commit a343ef2da3d3bc177874f76d77eaa961c48ece36

Authored by michael
1 parent 10bcf86b

changed getLookupCount query to retrieve count(*) from the db, instead of counting the rows in php


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2340 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/DocumentField.inc
@@ -315,18 +315,15 @@ class DocumentField { @@ -315,18 +315,15 @@ class DocumentField {
315 } 315 }
316 316
317 function getLookupCount($iDocumentFieldID){ 317 function getLookupCount($iDocumentFieldID){
318 - global $default, $lang_err_database; 318 + global $default;
319 319
320 $sql = $default->db; 320 $sql = $default->db;
321 - $result = $sql->query("SELECT * FROM " . $default->owl_metadata_table . " WHERE document_field_id = " . $iDocumentFieldID); 321 + $result = $sql->query("SELECT COUNT(*) AS count FROM " . $default->owl_metadata_table . " WHERE document_field_id = " . $iDocumentFieldID);
322 if ($result) { 322 if ($result) {
323 - $iCount = 0;  
324 - while ($sql->next_record()) {  
325 - $iCount++; 323 + if ($sql->next_record()) {
  324 + return $sql->f("count");
326 } 325 }
327 - return $iCount;  
328 } 326 }
329 - $_SESSION["errorMessage"] = $lang_err_database;  
330 return false; 327 return false;
331 } 328 }
332 } 329 }