<?php
class ProgrammerService
{
  var $project_table = "projects";
  var $dev_table = "developers";
  function ProgrammerService()
  {
    /* ustanawiamy polaczenie z baza danych */
    $this->db = mysql_connect("localhost", "user", "password");
    /* i wybieramy baze danych, której chcemy uzywac */
    mysql_select_db("amfphp");
    $this->methodTable = array(
    "getDevelopersByProject" => array(
      "access" => "zdalny",
      "description" => "Pobierz liste programistów",
      "returntype" => "Array"
    ),
    "getProjectsByDeveloper" => array(
      "access" => "zdalny",
      "description" => "Pobierz liste projektów",
      "returntype" => "Array"
    )
  );
}

/* mysql_connect oraz mysql_select_db znajduja sie konstruktorze */
function getDevelopersByProject($id)
{
  $sql = "select distinct name from developers d join (select * from developer_project_map where project_id = ".$id.") dpa on d.id = dpa.developer_id";
  return mysql_query($sql);
}
function getProjectsByDeveloper($id)
{
  $sql = "select distinct name from projects p join (select * from developer_project_map where developer_id = ".$id.") dpa on p.id = dpa.project_id";
  return mysql_query($sql);
  }
}
?>
