My post below works but is *not* the correct way. It only works because of default behavior. I'll re-post my understanding of what is "correct" soon.
LXII. Ingres II functions
| Aviso |
Esta extensión es EXPERIMENTAL. Esto significa que el comportamiento de esta extensión, los nombre de sus funciones y en definitiva TODO lo documentado sobre esta extensión, puede cambiar en una futura versión de PHP SIN AVISO. La advertencia queda hecha, y utilizar esta extensión queda bajo su propia responsabilidad. |
These functions allow you to access Ingres II database servers.
In order to have these functions available, you must compile php with Ingres support by using the --with-ingres option. You need the Open API library and header files included with Ingres II. If the II_SYSTEM environment variable isn't correctly set you may have to use --with-ingres=DIR to specify your Ingres installation directory.
When using this extension with Apache, if Apache does not start and complains with "PHP Fatal error: Unable to start ingres_ii module in Unknown on line 0" then make sure the environement variable II_SYSTEM is correctly set. Adding "export II_SYSTEM="/home/ingres/II" in the script that starts Apache, just before launching httpd, should be fine.
Nota: If you already used PHP extensions to access other database servers, note that Ingres doesn't allow concurrent queries and/or transaction over one connection, thus you won't find any result or transaction handle in this extension. The result of a query must be treated before sending another query, and a transaction must be commited or rolled back before opening another transaction (which is automaticaly done when sending the first query).
- Tabla de contenidos
- ingres_autocommit -- Switch autocommit on or off.
- ingres_close -- Close an Ingres II database connection
- ingres_commit -- Commit a transaction.
- ingres_connect -- Open a connection to an Ingres II database.
- ingres_cursor -- Gets a cursor name for a given link resource
- ingres_errno -- Gets the last ingres error number generated
- ingres_error -- Gets a meaningful error message for the last error generated
- ingres_errsqlstate -- Gets the last SQLSTATE error code generated
- ingres_fetch_array -- Fetch a row of result into an array.
- ingres_fetch_object -- Fetch a row of result into an object.
- ingres_fetch_row -- Fetch a row of result into an enumerated array.
- ingres_field_length -- Get the length of a field.
- ingres_field_name -- Get the name of a field in a query result.
- ingres_field_nullable -- Test if a field is nullable.
- ingres_field_precision -- Get the precision of a field.
- ingres_field_scale -- Get the scale of a field.
- ingres_field_type -- Get the type of a field in a query result.
- ingres_num_fields -- Get the number of fields returned by the last query
- ingres_num_rows -- Get the number of rows affected or returned by the last query
- ingres_pconnect -- Open a persistent connection to an Ingres II database.
- ingres_query -- Send a SQL query to Ingres II
- ingres_rollback -- Roll back a transaction.
On the three versions of Linux/Ingres I've worked on, I've always had to modify the following line in the example above:
while ($iirelation = ingres_fetch_object($link)) {
to:
while ($iirelation = ingres_fetch_object()) {
If not, PHP will return "Undefined property" notices.
However, it's my understanding that the following is the proper way to access the database (it works as expected):
<?php
// Connecting, selecting database
$link = ingres_connect('database', 'user', 'password')
or die('Could not connect: ' . ingres_error($link));
echo 'Connected successfully';
// Select from a table that exists in all Ingres databases
$query = 'SELECT * FROM iirelation';
$rs = ingres_query($link,$query) or die('Query failed: ' .
ingres_error($link));
// Print results in HTML
// relid - table name
// relowner - table owner
echo "<table>\n";
while ($iirelation = ingres_fetch_object($rs)) {
echo "\t<tr>\n";
echo "\t\t<td>" . $iirelation->relid . "</td>\n";
echo "\t\t<td>" . $iirelation->relowner . "</td>\n";
echo "\t</tr>\n";
}
echo "</table>\n";
// Commit transaction
ingres_commit($link);
// Closing connection
ingres_close($link);
?>
