Download PHP Integration with object relational DBMS
Transcript
char* make OID string(oidtype oid) {
char *toreturn;
char buffer[30];
int id = a getid(oid, TRUE);
if (a errorflag) AMOS ERROR;
sprintf(buffer, "#[OID %d]", id);
toreturn = (char *)emalloc(strlen(buffer)+1);
strcpy(toreturn,buffer);
return toreturn;
}
Figure 9: Transforming an object handle to an object string
gain an object handle out of an object string. The first thing to do is to retrieve the number,
the real OID, out of the given string. For example 1101 is the OID from the object string
#[OID 1101]. Next the location handle of the OID must be obtained, given its OID number.
It can be done by calling the Amos II function
a getobjectno(a connection c, int oid, int catcherror),
which returns the expected location handle.
3.5
Error Management
Another important topic for this project is error management integration of Amos II with
the one of PHP. First the Amos II error management is explained, then the PHP error
management and finally the integration.
Almost all functions of the external C interface have a flag as parameter that indicates the
kind of error handling. This parameter is an integer-value and can accept the values TRUE
or FALSE. As well most of the functions return an error flag that indicates the occurance of
an error. An example for such a function is
int a nextrow(a scan s, int catcherror)
with catcherror defining the kind of error handling. If this parameter is FALSE then Amos
II deals with the error and possibly shuts down the system. The other possibilty, TRUE,
means that the user has to deal with the error on his own, what is done in this project.
What happens if an error occurs? First of all there exists a global variable
int a errorflag;
which is 0 if the current Amos II functions ends normally or not equal to zero for the case
of an error. Some functions, as the one mentioned above, return this flag, and for other
functions this global flag must be investigated. For example like this:
if (a errorflag != 0) {
/* do some error handling here */
}
To receive information about the error, the following three global variables are of use.
21