Sorry, should probably have included some sample code for people who
look up this thread in the archive.
Step 1:
Open iSeries Navigator and go to the /usr/local/Zend/Core/etc
directory in the IFS.
Copy and save the current freetds.conf file (freetds_old.conf).
Modify the freetds.conf file to add a Microsoft connection.
My connection was to a SQL Server 2000 host, so it looked like:
[MyHost]
host = hostmachinename.companynetwork.com
port = 1433
tds version = 8.0
Save the modified freetds.conf file.
I stopped and re-started everything in the Zend setup tool just
make sure the new configuration file was picked up. This
might not be necessary.
Step 2:
<?php
// Connect to the database host
$conn = mssql_connect('MyHost', 'username', 'password');
if ($conn) {
// Select the database
mssql_select_db("MYDATABASE");
// Define and run the query
$item = "4960001";
$ps_item_query = "SELECT BUSINESS_UNIT,CUST_ID,ITEM FROM PS_ITEM
WITH(NOLOCK) WHERE ITEM='$item'";
$ps_item_result = mssql_query($ps_item_query);
// Display the results
while ( $ps_item_record = mssql_fetch_array($ps_item_result) ) {
print ("<tr><td>" . $ps_item_record["BUSINESS_UNIT"] . "</td><td>" .
$ps_item_record["CUST_ID"] . "</td><td>" . $ps_item_record["ITEM"] .
"</td></tr>");
}
print ("</table>");
}
?>
Thanks again,
Kelly
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Mike Pavlak
Sent: Tuesday, July 07, 2009 8:51 AM
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] PHP - remote connection to SQL Server from Zend
CoreoniSeries
Kelly,
Have you checked out Page 160 of the "Zend Core for i5/OS User Guide"?
This section discusses the configuration steps for MS SQL Server on i5.
The FREETDS files should already be there and you may use an IP address
instead of a DNS entry. DNS would be a convenience so you don't have
hard-coded IP's. Your LAN team admin may have a local DNS server where
they have these entries installed. The user guide is available online
here:
http://files.zend.com/help/Zend-Core-i5/zend-core-i5.htm (search
mssql and you should get to link:
http://files.zend.com/help/Zend-Core-i5/appendix_a.htm ) and can be
downloaded in PDF format from here:
http://www.zend.com/topics/Zend-Core-User-Guide-i5OS-V261.pdf
Regards,
Mike
mike.p@xxxxxxxx Cell: (408)679-1011 Office: (815)722-3454
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Kelly Cookson
Sent: Monday, July 06, 2009 3:26 PM
To: web400@xxxxxxxxxxxx
Subject: [WEB400] PHP - remote connection to SQL Server from Zend Core
oniSeries
We run a custom order entry system using a DB2 database on an iSeries
(V5R4). We also run PeopleSoft Receivables on a Microsoft SQL Server
database. I want to write PHP scripts that can display data from both
the DB2 database and the SQL Server database.
I'm running the Zend Core on the iSeries. I can easily access DB2 data
on the iSeries using the PHP Toolkit. No problem there.
But how do I connect to a remote SQL Server database from a PHP script
running in the Zend Core on an iSeries? Most of the online tips I have
seen talk about setting up a DNS to the SQL Server database. Can I set
up DNS for a SQL Server database on an iSeries (V5R4)? If so, where can
I find the instructions for doing so?
Thanks,
Kelly Cookson
Senior Programmer\Analyst
Dot Foods, Inc.
As an Amazon Associate we earn from qualifying purchases.