Example PHP Client
this is a sample from the OPIIceServer , a Ice interface that exports the ODABA functionality
class iceT {
private $host = "localhost";
private $port = "10000";
public $sessionp;
public $sessionfactory;
public $session;
public $objectfactory;
public function __construct($name){
global $ICE;
Ice_loadProfile($name);
try{
$sessionp = $ICE->stringToProxy("session:tcp -h $this->host -p $this->port:udp -h $this->host -p $this->port -h $t
$sessionp = $sessionp->ice_twoway();
$sessionfactory = $sessionp->ice_uncheckedCast("::OPI::SessionFactory");
$session = $sessionfactory->CreateProxy("php".time());
$this->objectfactory = $session->CreateSession();
} catch(Ice_LocalException $ex) {
echo "warning impossible to continue: ".$ex->unknown."\n";
var_dump($ex);
exit(0);
}
}
};
class opiI extends iceT{
protected $odabaclient;
protected $dictionary;
protected $database;
/**
\brief path of databases
a location that can be accessed with the opiice user on the machine the opiiceserver is running
\lang{de} pfad zu den datenbanken
ein dateisystempfad den der opiice nutzer auf dem computer wo der opiiceserver laeuft lesen und schreiben darf
*/
protected $basepath = "/data/data/";
/**
\brief Konstruktor
opens the profile "opi" /etc/ice/profile.ini
creates empty handles from the objectfactory
*/
public function __construct(){
parent::__construct("opi");
$this->odabaclient = $this->objectfactory->GetODABAClient();
// the dictionary is in short the structure information
// you need it to know what is where in the database
// technical it is just a database and can be used like it
$this->dictionary = $this->objectfactory->GetDictionaryHandle();
// the database is the storage for the data
$this->database = $this->objectfactory->GetDatabaseHandle();
}
/**
\brief Open Data
opens the database and the dictionary from the $this->basepath with a
naming convention (*.dev: dictionary, *.dat: database)
*/
public function Open($dbname,$readonly=0){
$this->dictionary->OpenDictionary($this->odabaclient,$this->basepath.$dbname.".dev",($readonly?OPI_PIACC::piaREAD:OPI_PIACC::piaWRITE)
,false //net
,-1 //version
,OPI_ResourceTypes::resAUTOMATIC //resourcetype
,false); // sysenv
$this->database->OpenDatabase($this->dictionary,$this->basepath.$dbname.".dat",($readonly?OPI_PIACC::piaREAD:OPI_PIACC::piaWRITE)
,false //net
,false //online
,-1 //version
,OPI_ResourceTypes::resAUTOMATIC
,false); //sysenv
}
/**
\brief Open a Extent
this wraps the access to a extent (someting comparable to a table) to a single call
the returned propertyhandle can be used for operation
\lang{de} Oeffnet einen Extent
Die erstellung auf eines extents (etwas vergleichbar mit einer tabelle) zu einem funktionsaufruf zusammengefasst.
das zurueckgegebene propertyhandle kann fuer alle weiteren datenbankoperationen benutzt werden
*/
public function Extent($path,$readonly=0){
$ph = $this->objectfactory->GetPropertyHandle();
$ph->OpenExtent($this->database,$path,($readonly?OPI_PIACC::piaREAD:OPI_PIACC::piaWRITE)
,false //transient
,""); //keyname
return $ph;
}
};
$action = $opi->Extent("Action");
$note = $action->GetPropertyHandle("notes");
$note->GetAtPosition(0);
echo $note->GetString()