Tibco General Interface & Mysql?: Generated by Clearspace On 2011-01-07-06:00 1
Tibco General Interface & Mysql?: Generated by Clearspace On 2011-01-07-06:00 1
myPage.php?product_category=someCategory
See this post : Howto: Establish a connection to a MySQL Database in Tibco GI - The
answer!
GI is a client to HTTP based services (usually XML or SOAP, but also JSON, and anything
else over HTTP if need be)...
Here's a few things I found on creating XML services with PHP and mySQL...
Build your own Web Service with PHP and XML-RPC [PHP & MySQL ...Harry takes us one
step further into the world of Web Services. Here he explains how to build your own Web
Service - a news feed - using PHP and XML-RPC.
Use XML to Build Services Cheaply Using PHP and MySQLUsing the open source
technologies of PHP and MySQL you can create server-side applications that abstract
databases and return XML.
I don't have anything specific beyond going to the PHP/mySQL sites and reading up on how
to install and use them.
Once you know how to use PHP/mySQL to generate a regular HTML page, you can easily
modify your PHP code to generate XML instead.
At this point, you will have a PHP page that will return XML (preferably CDF) that you can
then request from within your GI application using the classes within the jsx3.net package
(Request, Form, and Service).
--Luke
If I understand your question, you already have a PHP that will return XML data in some
arbitrary format. You'd like to render this XML is a GI data control, like a list?
The trick is that GI uses what we call Common Data Format as a way to vastly simplify how
data gets into UI components without having to write XML. All GI data components which
render data understand how to render ZCDF, we've written the XSL for you. You could
rewrite the XSL for each of your onscreen GUI components to understand your XML (ugh),
or you could convert your XML into CDF (whee).
If you're using 3.2+, then it's much easier. You can use the new data mapper to create a
mapping rule (what we call Common Transfer Format or CXF) between your XML and GI's
CDF. Look here: GI 3.6 JSON sample using Yahoo Travel Sample : RSS reader
peachey
In case anyone is interested, here is the PHP code I used to transform mySQL query results
to XML. Michael uses this exact XML hierarcy structure in his latest WebEx Video Tutorial
on transforming XML to CDF http://tinyurl.com/8bxbl.
This could easily be converted to output CDF docs too, but would this save me any work, or
would this create another step for me?
Yes, you should output in CDF, which will save you a step on the client side (GI) from having
to convert the generic XML to CDF for display in GI --dhwang
<?
// PHP File to query a MySQL database and
generate the resultset as an
// XML Hierarcy. _The XML is generated as
CDF XML, so no conversion on GI is needed_
// The XML will be generated using a
<data><record> hierarchy with the
// result having the indices stored as
if
($condition==
"reps")
{
$query =
"SELECT * FROM reps";
}
while
($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
$i=0;
foreach ($line as $col_value)
{
$fieldname=mysql_field_name($result,$i);
if
($i==0)
{
// For the first column (where $i=0) output
the <record> tag
// with the id set to the column value and
then begin the rowitems child
print
"<record jsxid='$col_value' ";
}
else
$i++;
}
// When done, close the record tag for this
record
print (
"/>");
}
// When done with all the records, close
the XML tag for the document
print(
" </data>");
// Clear up the resultset
mysql_free_result($result);
// And close the database.
mysql_close($db);
?>
You would then get a response like this:
As far as your question about whether you should output CDF or some arbitrary XML,
outputting CDF will save a step on the client. That way you can simple get your document
and put it into cache, obviating the conversion step. All of that being said, the conversion
effort of most documents (< 500 records or so) is pretty negligable. So, if you have easy
control over the back end, output CDF. If you don't, no worries. Just use one of the two
conversion techniques.
FYI, the arbitrary XML I used in the video isn't anything special, it was just some XML that
someone else had in their post in the forum when they asked a similar question.
Michael
This resource was generated from the following thread: Tibco & MySql?