From the $formValues array retrieve the value
of the catalogId field.
$catalogId=trim($formValues['catalogId']);
Next, we shall use the PHP Oracle extension to connect with the Oracle
database and determine if a Catalog table row is defined for the catalog
id value input in the input form. Define variables $username,
170 8 Ajax with PHP-Xajax
$password, and $db for Oracle database username, password and
database. Specify the $db variable value as the database SID value in the
/NETWORK/ADMIN/tnsnames.ora file.
$username='OE';
$password='';
$db='(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =localhost)(PORT
= 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)';
Obtain a connection with the database using oci_connect function.
$connection = oci_connect($username, $password, $db);
Prepare an Oracle statement to select a row of data for the catalog id
value input in the form. The oci_parse(conection, query)
function is used to compile a statement.
$stmt = oci_parse($connection, ???SELECT * from
OE.CATALOG WHERE catalogId=??™???.$catalogId.?????™???);
Run the SQL query with the oci_execute(statement) function.
$r = oci_execute($stmt);
Fetch the rows in the result set using the
oci_fetch_all(statement, result) function.
$nrows = oci_fetch_all($stmt, $result);
The oci_fetch_all function returns the number of rows in the
result set. If the result set is empty, a Catalog table row for the catalog
id value is not defined in the database table.
Pages:
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157