« Kill runaway Postgres threads | Main | Alternately colour the rows in a table with jQuery »

October 11, 2011

Student class needs to be adjusted

	function get_hash_by_uun($uun){
		
		return $this->get_hash_by_id($this->get_id_by_uun($uun)); 
		
		}

	function get_id_by_uun($uun){

		$m = (int) str_replace('s', '', $uun);
		
		$reply = just::sql(sprintf("select student_id from student_full where matriculation_number = %d", $m));
		
		return $reply['first_row']['student_id'];		

		}
		
	function get_uun_by_id($id){
	
		$reply = just::sql(
			sprintf("select case
			when char_length(matriculation_number::varchar) = 5 then 's00'||matriculation_number
			when char_length(matriculation_number::varchar) = 6 then 's0'||matriculation_number
			else 's'||matriculation_number end as uun from student_full where student_id = %d", (int) $id)
			);
	
		return $reply['first_row']['uun'];
	
		}

Tags: PHP

Posted by pj at October 11, 2011 06:42 PM

Comments