Natively Connect to JD Edwards Data in PHP

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
The CData ODBC driver for JD Edwards enables you to create PHP applications with connectivity to JD Edwards data. Leverage the native support for ODBC in PHP.

Drop the CData ODBC Driver for JD Edwards into your LAMP or WAMP stack to build JD Edwards-connected Web applications. This article shows how to use PHP's ODBC built-in functions to connect to JD Edwards data, execute queries, and output the results.

Configure a DSN

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.

The driver connects to JD Edwards through your Application Interface Services (AIS) Server. Set the following connection properties:

  • URL: The base HTTPS URL of your AIS Server (e.g., https://jde-ais.example.com:8300).
  • User: Your JD Edwards username.
  • Password: Your JD Edwards password.
  • Environment (optional): The JD Edwards environment to use (e.g., PD920 for production or DV920 for development). If not specified, the AIS Server's default environment is used.
  • Role (optional): The JD Edwards role for the session. If not specified, the AIS Server's default role is used.
  • DeviceName (optional): An identifier for the connecting device or application, used for auditing and logging on the AIS Server.
  • Jasserver (optional): The specific Java Application Server (JAS) instance to route requests through, useful in clustered environments.

Choosing Which Data Is Exposed

JD Edwards organizes tables and business views by System Code, and the driver exposes each System Code as its own schema. Use these properties to control which schemas are available:

  • DataModel: One or more ERP modules (comma-separated) whose System Codes are exposed as schemas, or All to expose every System Code in the connected instance. Defaults to FinancialManagement.
  • SystemCodes: A comma-separated list of additional System Codes to expose alongside those from DataModel (e.g., 42,43).

When you connect, the driver sends your credentials to the AIS Server to obtain a session token and caches it. The driver requests a new token automatically before the session expires.

Establish a Connection

Open the connection to JD Edwards by calling the odbc_connect or odbc_pconnect methods. To close connections, use odbc_close or odbc_close_all.


$conn = odbc_connect("CData ODBC JDEdwards Source","user","password");

Connections opened with odbc_connect are closed when the script ends. Connections opened with the odbc_pconnect method are still open after the script ends. This enables other scripts to share that connection when they connect with the same credentials. By sharing connections among your scripts, you can save system resources, and queries execute faster.


$conn = odbc_pconnect("CData ODBC JDEdwards Source","user","password");
...
odbc_close($conn); //persistent connection must be closed explicitly

Create Prepared Statements

Create prepared statements and parameterized queries with the odbc_prepare function.


$query = odbc_prepare($conn, "SELECT * FROM AccountsPayable.AccountLedger WHERE BusinessUnit = ?");

Execute Queries

Execute prepared statements with odbc_execute.


$conn = odbc_connect("CData ODBC JDEdwards Source","user","password");
$query = odbc_prepare($conn, "SELECT * FROM AccountsPayable.AccountLedger WHERE BusinessUnit = ?");
$success = odbc_execute($query, array('100'));
  

Execute nonparameterized queries with odbc_exec.


$conn = odbc_connect("CData ODBC JDEdwards Source","user","password");
$query = odbc_exec($conn, "SELECT DocumentNumber, Amount FROM AccountsPayable.AccountLedger WHERE BusinessUnit = '100'");
  

Process Results

Access a row in the result set as an array with the odbc_fetch_array function.


$conn = odbc_connect("CData ODBC JD Edwards data Source","user","password");
$query = odbc_exec($conn, "SELECT DocumentNumber, Amount FROM AccountsPayable.AccountLedger WHERE BusinessUnit = '100'");
while($row = odbc_fetch_array($query)){
 echo $row["DocumentNumber"] . "\n";
}

Display the result set in an HTML table with the odbc_result_all function.


$conn = odbc_connect("CData ODBC JD Edwards data Source","user","password");
$query = odbc_prepare($conn, "SELECT * FROM AccountsPayable.AccountLedger WHERE BusinessUnit = ?");
$success = odbc_execute($query, array('100'));
if($success)
  odbc_result_all($query);

More Example Queries

You will find complete information on the driver's supported SQL in the help documentation. The code examples above are JD Edwards-specific adaptations of the PHP community documentation for all ODBC functions.

Ready to get started?

Download a free trial of the JD Edwards ODBC Driver to get started:

 Download Now

Learn more:

JD Edwards Icon JD Edwards ODBC Driver

The JD Edwards ODBC Driver is a powerful tool that allows you to connect with live data from JD Edwards, directly from any applications that support ODBC connectivity.

Access JD Edwards data like you would a database - read JD Edwards AccountLedger, ProposalofPayment, ContractRevenueSummary, EmployeeEnrollment, RentIncreaseAmounts, etc. through a standard ODBC Driver interface.