Kevin,
At the time I set this up here, there was no PDO for U2 in PHP, so I
looked into the UOJ libraries. Using them requires a bridge. There is a
SourceForge project that works well. I am currently using Zend Server CE.
No cost and it does the job, in fact it optimizes the PHP code.
I build a Java class for each project and include it in a java archive
that I put in the same directory as the UOJ includes. The java object
uses Uniobjects for Java to access Unidata. Although, Uniobjects has a
rich command set, I have come to the conclusion that the Java layer should
be minimized as much as possible. I just use the java to run UniBasic
subroutines. It passes in the parameters and returns the result. This is
partly to reduce traffic, but mostly because I want to push the database
logic to the database.
It would be better if there was a PDO for U2, but this approach works.
Here is a example.
****************
In the javascript function make a request object call to PHP on the
webserver
var XHR = GetXHR();
var urlstr = "getNextId.php";
urlstr += "?sid=" + Math.random();
XHR.onreadystatechange = function() {
if(XHR.readyState === 4) {
// Process the results in XHR.responseText
}
};
XHR.open("GET",urlstr,true);
XHR.send(null);
return;
*************
In PHP create an object from the java archive for the project and call the
java function. Must be cataloged.
$cnU2 = new Java('com.ntnbower.webutil.u2ProjectName');
$cnU2->setAccount("PRODUCTION");
echo $cnU2->getNextId(); // This is returned to javascript as reponseText
return;
*********
In java
public String getNextId() {
OpenU2Session();
UniSubroutine uSub = uSession.subroutine("getNextId", 1);
uSub.call();
return uSub.getArg(0);
}
**************
In UniBasic. Get the requested data and return it in RESULT
SUBROUTINE getNextId(RESULT)
OPEN 'FILENAME' TO F.NSH THEN
READU R.NSH FROM F.NSH, 'NEXT_ID' THEN
RESULT = R.NSH<1>
R.NSH<1> += 1
WRITE R.NSH TO F.NSH, 'NEXT_ID'
END
CLOSE F.NSH
END ELSE
RESULT = "-1"
END
END
RETURN
Charles Shaffer
Senior Analyst
NTN-Bower Corporation
Kevin King <[email protected]>
Sent by: [email protected]
05/19/2011 11:26 PM
Please respond to U2 Users List
To: U2 Users List <[email protected]>
cc:
Subject: Re: [U2] Uniobjects - What Is It?
I'm interested to know more about how folks are using UOJ with PHP. I've
tried making that connection numerous times but .. just haven't been
successful yet. Big fan of PHP but using the UO connection on Windows is
... less than optimal for my needs.
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users