From: <vb...@us...> - 2002-08-25 15:06:00
|
Update of /cvsroot/mantisbt/mantisbt/core In directory usw-pr-cvs1:/tmp/cvs-serv6626/core Modified Files: custom_attribute_api.php Log Message: Added caching to attribute_get_all() which reduces the number of executed queries from 124 to 50!!! Index: custom_attribute_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/custom_attribute_api.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- custom_attribute_api.php 25 Aug 2002 08:14:59 -0000 1.2 +++ custom_attribute_api.php 25 Aug 2002 15:05:58 -0000 1.3 @@ -16,17 +16,22 @@ # -------------------- # return the custom list for the specified project id and the specified attribute function attribute_get_all( $p_parameter, $p_project_id ) { - global $g_mantis_project_customization_table; + global $g_mantis_project_customization_table, $g_cache_custom_attr; $c_project_id = (integer)$p_project_id; - $c_parameter = addslashes($p_parameter); + $c_parameter = addslashes($p_parameter); + + if ( !isset( $g_cache_custom_attr[$c_project_id][$c_parameter] ) ) + { + $query = "SELECT * + FROM $g_mantis_project_customization_table + WHERE project_id='$c_project_id'"; + $result = db_query( $query ); + $row = db_fetch_array( $result ); + $g_cache_custom_attr[$c_project_id][$c_parameter] = $row[0]; + } - $query = "SELECT $c_parameter - FROM $g_mantis_project_customization_table - WHERE project_id='$c_project_id'"; - $result = db_query( $query ); - $row = db_fetch_array( $result ); - return explode_enum_string( $row[0] ); + return explode_enum_string( $g_cache_custom_attr[$c_project_id][$c_parameter] ); } # -------------------- |