There are two resource types used in the FairCom DB PHP module. The first is the connection identifier for a FairCom DB SQL connection. The second resource holds the result of a query.
For example, the following code demonstrates how to connect to FairCom DB SQL, execute a query, print resulting rows and disconnect from a FairCom DB SQL database:
c-treePHP Example
<?php
/* Connecting, selecting database */
$ses = ctsql_connect("ctreeSQL","ADMIN","ADMIN")
or die("Could not successfully connect to FairCom DB SQL: " . ctsql_error());
echo "Successfully connected to FairCom DB SQL!";
/* Performing SQL query */
$query = "SELECT * FROM my_table";
$result = ctsql_query($query) or die("Query failed : " . ctsql_error());
/* Printing results in HTML */
echo "<table>\n";
while ($line = ctsql_fetch_assoc($result)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
/* Free resultset */
ctsql_free_result($result);
/* Closing connection */
ctsql_close($ses);
?>
PDO SSL Security
A new parameter has been added to the connection string to indicate if SSL should be used:
For example:
$ses = new PDO('ctsql:port=6597;host=localhost;dbname=ctreeSQL;ssl=BASIC', 'admin', 'ADMIN');