spacer
spacer search

SwissCenter

Search
spacer
Main Menu
Home
Documentation + FAQ
Screenshots
Downloads
Forums
Bug Tracking
History
Login
Username

Password

Remember me
?
No account yet?

Locations of visitors to this page

 
Home arrow Forums

SwissCenter Forums  


Small update to rating.php (v1.16) - 2007/05/14 08:31 Hi,

I made a couple of small changes to the code in rating.php, see below:

Changes:
$current_rank = db_value("select rank from certificates where cert_id='$id'");

if ($current_rank != false)

return db_value("select cert_id from certificates where rank >='$current_rank' and scheme = '$target_scheme' order by rank limit 1");

Updated code:

Code:

    function get_nearest_cert_in_scheme($id$target_scheme'')   {     if ( $target_scheme == '')       $target_scheme get_rating_scheme_name();     $current_rank db_value("select rank from certificates where cert_id='$id'");     if ($current_rank != false)       return db_value("select cert_id from certificates where rank >='$current_rank' and scheme = '$target_scheme' order  by rank limit 1");     else       return false;   }



Yours, mvdkleijn
Player: Pinnacle ShowCenter 1000 (wired)
Server: Ubuntu Dapper LTS
  | | The administrator has disabled public write access.
Re: Small update to rating.php (v1.16) - 2007/05/14 08:53 Quotes aren't required for comparing against rank and cert_id as they are integers.

FYI: The following statement would fail on other database systems as the rank would be converted to the same datatype as the constant (a string) and then compared against '2' - resulting in '11' < '2'.

Code:

 Select cert_id from certificates where rank <='2' 

Player : Pinnacle Showcenter 200 (wired ethernet)
Server : HP MediaSmart EX470 NAS (Windows Home Server / Sempron CPU / 2Gb RAM / 2.0 Tb Storage).

  | | The administrator has disabled public write access.
Re: Small update to rating.php (v1.16) - 2007/05/14 09:03 Point taken.

However, then there are some inconsistencies in the code, because in rating.php you can also find:

Code:

   function get_cert_name($cert_id)   {     return db_value("select name from certificates where cert_id='$cert_id'");   }




Which I didn't touch yet is also quoting cert_id... why quote one and not the other?

Sorry for nitpicking btw..
Player: Pinnacle ShowCenter 1000 (wired)
Server: Ubuntu Dapper LTS
  | | The administrator has disabled public write access.
Re: Small update to rating.php (v1.16) - 2007/05/14 09:07 Oops. That one needs correcting Player : Pinnacle Showcenter 200 (wired ethernet)
Server : HP MediaSmart EX470 NAS (Windows Home Server / Sempron CPU / 2Gb RAM / 2.0 Tb Storage).

  | | The administrator has disabled public write access.
spacer
 

Screenshots

www.flickr.com
This is a Flickr badge showing public photos from swisscenter. Make your own badge here.


 

Mambo is Free Software released under the GNU/GPL License.
spacer