<?php
	require_once '../../../autoload.php';

	$result = array (
			"status"	=> 'KO',
			"results"	=> array ()
	);
	
	$pdo = getPDO ();
		
	if ( $pdo )
	{
		$room_id = -1;
		
		if ( isset($_POST['room_id']) )		$room_id = $_POST['room_id'];
		error_log ( " room_id : " .$room_id );

		$sql = "select room_id,name as room_name from room where room_id=:room_id and removed = false";

		$s0 = $pdo->prepare ( $sql );

		$s0->bindParam ( ':room_id', $room_id );
		
		if ( $s0->execute () )
		{
			$result['status'] ='OK';

			$d0 = $s0->fetchAll ();

			for ( $i=0; $i<count($d0); $i++ )
			{
				$res = array (	"room_id" 			=> $d0[$i]['room_id'],
								"name"				=> $d0[$i]['room_name'] );

				array_push ( $result['results'], $res );
			}
		}
	}
	
	header('Content-type: application/json');
	
	echo json_encode ( $result );
?>