0% found this document useful (0 votes)
77 views5 pages

Tibco General Interface & Mysql?: Generated by Clearspace On 2011-01-07-06:00 1

The document discusses connecting a Tibco General Interface (GI) application to a MySQL database using PHP. It provides code samples for querying a MySQL database and outputting the results as XML or Common Data Format (CDF). Outputting the data as CDF is recommended as it avoids needing to convert the data to CDF in the GI application. Advice is given on using the PHP MySQL extension to generate XML or CDF output from database queries and rendering it in a GI list component.

Uploaded by

gottammohanreddy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

Tibco General Interface & Mysql?: Generated by Clearspace On 2011-01-07-06:00 1

The document discusses connecting a Tibco General Interface (GI) application to a MySQL database using PHP. It provides code samples for querying a MySQL database and outputting the results as XML or Common Data Format (CDF). Outputting the data as CDF is recommended as it avoids needing to convert the data to CDF in the GI application. Advice is given on using the PHP MySQL extension to generate XML or CDF output from database queries and rendering it in a GI list component.

Uploaded by

gottammohanreddy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Tibco General Interface & MySql?

I would like to send something like this:

myPage.php?product_category=someCategory

and have the results in a list box.

I think that is a good newbie project for me.

Anyone have any advice?

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...

Output mySQL data as XML with PHP

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.

http://www.sitepoint.com/article/own-web-service-php-xml-rpc - 33k - Cached - Similar pages

Instant XML with PHP and PEAR::XML_Serializer PHP & MySQL


TutorialsPEAR::XML_Serializer is PHP's Swiss Army Knife for XML. ... building REST-based
Web services, storing data in XML for later recall by your applications, ...

http://www.sitepoint.com/article/xml-php-pear-xml_serializer - 45k - Cached - Similar pages

More results from www.sitepoint.com

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.

http://www.devx.com/xml/article/16418 - 78k - Cached - Similar pages

Generated by Clearspace on 2011-01-07-06:00


1
Tibco General Interface & MySql?

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

Generated by Clearspace on 2011-01-07-06:00


2
Tibco General Interface & MySql?

attributes, and the item storing


// the column values as attributes to
compress the xml to the smallest
// usable footprint.

// Clear the response buffer


flush();

// Output the XML headers


echo(
"<?xml version='1.0' ?>");
echo(
"<data jsxid='jsxroot'>");

// Pull the service type from the URL


parameter service=whatever
$condition = $_GET[
'service'];

// Open the database and select


database
$db = mysql_connect(
"localhost",
"root" ,
"");
@ mysql_select_db(
"products", $db) or die(
"Unable to Select Database");

// Generate the query to run based on the


condition passed in the service parameter

if
($condition==
"reps")
{
$query =
"SELECT * FROM reps";
}

// Execute the query to get the


results
$result = mysql_query($query) or die(
"Query Failed");

// Iterate throught the result rows


$recordcount = mysql_numrows($result);

while
($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
$i=0;
foreach ($line as $col_value)

Generated by Clearspace on 2011-01-07-06:00


3
Tibco General Interface & MySql?

{
$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

// For all other rows, output the


fieldname=fieldvalue attributes on rowitem
print (
" $fieldname='$col_value'");

$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:

<?xml version="1.0" ?>


<data jsxid="jsxroot">
<record jsxid="4" first_name="Joe"
last_name="Hendrickson" role="USER" email_address="[email protected]"
user_password="joejoe" setup_completed="" company_name="CHMI"
street="chmi street" street2="chmi street2" city="Keokuk"
state="Iowa" country="United States" zipcode="52632"
bus_phone="319-555-1212" mob_phone="319-555-1212"
fax="319-555-1212" account_approved="1" discount_percent=""
account_type="CASH" />
</data>

Generated by Clearspace on 2011-01-07-06:00


4
Tibco General Interface & MySql?

Thanks for posting this, I'm sure it will be useful.

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?

Generated by Clearspace on 2011-01-07-06:00


5

You might also like