php-doc-en/functions/ovrimos.xml
2001-12-12 20:47:43 +00:00

821 lines
25 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.14 $ -->
<reference id="ref.ovrimos">
<title>Ovrimos SQL functions</title>
<titleabbrev>OvrimosSQL</titleabbrev>
<partintro>
<para>
Ovrimos SQL Server, is a client/server, transactional RDBMS
combined with Web capabilities and fast transactions.
</para>
<para>
Ovrimos SQL Server is available at <ulink
url="&url.ovrimos;">www.ovrimos.com</ulink>. To enable ovrimos
support in PHP just compile php with the '--with-ovrimos'
parameter to configure script. You'll need to install the sqlcli
library available in the Ovrimos SQL Server distribution.
</para>
<para>
<example>
<title>
Connect to Ovrimos SQL Server and select from a system table
</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = ovrimos_connect ("server.domain.com", "8001", "admin", "password");
if ($conn != 0) {
echo ("Connection ok!");
$res = ovrimos_exec ($conn, "select table_id, table_name from sys.tables");
if ($res != 0) {
echo "Statement ok!";
ovrimos_result_all ($res);
ovrimos_free_result ($res);
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
This will just connect to SQL Server.
</para>
</partintro>
<refentry id="function.ovrimos-connect">
<refnamediv>
<refname>ovrimos_connect</refname>
<refpurpose>Connect to the specified database</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_connect</function></funcdef>
<paramdef>string <parameter>host</parameter></paramdef>
<paramdef>string <parameter>db</parameter></paramdef>
<paramdef>string <parameter>user</parameter></paramdef>
<paramdef>string <parameter>password</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_connect</function> is used to connect to the
specified database.
</para>
<para>
<function>ovrimos_connect</function> returns a connection id
(greater than 0) or 0 for failure. The meaning of 'host' and
'port' are those used everywhere in Ovrimos APIs. 'Host' is a
host name or IP address and 'db' is either a database name, or a
string containing the port number.
</para>
<para>
<example>
<title><function>ovrimos_connect</function> Example</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = ovrimos_connect ("server.domain.com", "8001", "admin", "password");
if ($conn != 0) {
echo "Connection ok!";
$res=ovrimos_exec ($conn, "select table_id, table_name from sys.tables");
if ($res != 0) {
echo "Statement ok!";
ovrimos_result_all ($res);
ovrimos_free_result ($res);
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
The above example will connect to the database and print out the
specified table.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-close">
<refnamediv>
<refname>ovrimos_close</refname>
<refpurpose>Closes the connection to ovrimos</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>ovrimos_close</function></funcdef>
<paramdef>int <parameter>connection</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_close</function> is used to close the specified
connection.
</para>
<para>
<function>ovrimos_close</function> closes a connection to
Ovrimos. This has the effect of rolling back uncommitted
transactions.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-longreadlen">
<refnamediv>
<refname>ovrimos_longreadlen</refname>
<refpurpose>
Specifies how many bytes are to be retrieved from long datatypes
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_longreadlen</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>int <parameter>length</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_longreadlen</function> is used to specify how
many bytes are to be retrieved from long datatypes.
</para>
<para>
<function>ovrimos_longreadlen</function> specifies how many bytes
are to be retrieved from long datatypes (long varchar and long
varbinary). Default is zero. It currently sets this parameter
the specified result set. Returns &true;.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-prepare">
<refnamediv>
<refname>ovrimos_prepare</refname>
<refpurpose>Prepares an SQL statement</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_prepare</function></funcdef>
<paramdef>int <parameter>connection_id</parameter></paramdef>
<paramdef>string <parameter>query</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_prepare</function> is used to prepare an SQL statement.
</para>
<para>
<function>ovrimos_prepare</function> prepares an SQL statement
and returns a result_id (or &false; on failure).
</para>
<para>
<example>
<title>Connect to Ovrimos SQL Server and prepare a statement</title>
<programlisting role="php">
<![CDATA[
<?php
$conn=ovrimos_connect ("db_host", "8001", "admin", "password");
if ($conn!=0) {
echo "Connection ok!";
$res=ovrimos_prepare ($conn, "select table_id, table_name
from sys.tables where table_id=1");
if ($res != 0) {
echo "Prepare ok!";
if (ovrimos_execute ($res)) {
echo "Execute ok!\n";
ovrimos_result_all ($res);
} else {
echo "Execute not ok!";
}
ovrimos_free_result ($res);
} else {
echo "Prepare not ok!\n";
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
This will connect to Ovrimos SQL Server, prepare a statement and
the execute it.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-execute">
<refnamediv>
<refname>ovrimos_execute</refname>
<refpurpose>Executes a prepared SQL statement</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>bool <function>ovrimos_execute</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>array
<parameter><optional>parameters_array</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_execute</function> is used to execute an SQL
statement.
</para>
<para>
<function>ovrimos_execute</function> executes a prepared
statement. Returns &true; or &false;.
If the prepared statement
contained parameters (question marks in the statement), the
correct number of parameters should be passed in an array. Notice
that I don't follow the PHP convention of placing just the name
of the optional parameter inside square brackets. I couldn't
bring myself on liking it.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-cursor">
<refnamediv>
<refname>ovrimos_cursor</refname>
<refpurpose>Returns the name of the cursor</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_cursor</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_cursor</function> is used to get the name of
the cursor.
</para>
<para>
<function>ovrimos_cursor</function> returns the name of the
cursor. Useful when wishing to perform positioned updates or
deletes.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-exec">
<refnamediv>
<refname>ovrimos_exec</refname>
<refpurpose>Executes an SQL statement</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_exec</function></funcdef>
<paramdef>int <parameter>connection_id</parameter></paramdef>
<paramdef>string <parameter>query</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_exec</function> is used to execute an SQL
statement.
</para>
<para>
<function>ovrimos_exec</function> executes an SQL statement
(query or update) and returns a result_id or &false;. Evidently,
the SQL statement should not contain parameters.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-fetch-into">
<refnamediv>
<refname>ovrimos_fetch_into</refname>
<refpurpose>Fetches a row from the result set</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>bool <function>ovrimos_fetch_into</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>array <parameter>result_array</parameter></paramdef>
<paramdef>string
<parameter><optional>how</optional></parameter>
</paramdef>
<paramdef>int
<parameter><optional>rownumber</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_fetch_into</function> is used to fetch a row
from the result set.
</para>
<para>
<function>ovrimos_fetch_into</function> fetches a row from the
result set into 'result_array', which should be passed by
reference. Which row is fetched is determined by the two last
parameters. 'how' is one of 'Next' (default), 'Prev', 'First',
'Last', 'Absolute', corresponding to forward direction from
current position, backward direction from current position,
forward direction from the start, backward direction from the end
and absolute position from the start (essentially equivalent to
'first' but needs 'rownumber'). Case is not
significant. 'Rownumber' is optional except for absolute
positioning. Returns &true; or &false;.
</para>
<para>
<example>
<title>A fetch into example</title>
<programlisting role="php">
<![CDATA[
<?php
$conn=ovrimos_connect ("neptune", "8001", "admin", "password");
if ($conn!=0) {
echo "Connection ok!";
$res=ovrimos_exec ($conn,"select table_id, table_name from sys.tables");
if ($res != 0) {
echo "Statement ok!";
if (ovrimos_fetch_into ($res, &$row)) {
list ($table_id, $table_name) = $row;
echo "table_id=".$table_id.", table_name=".$table_name."\n";
if (ovrimos_fetch_into ($res, &$row)) {
list ($table_id, $table_name) = $row;
echo "table_id=".$table_id.", table_name=".$table_name."\n";
} else {
echo "Next: error\n";
}
} else {
echo "First: error\n";
}
ovrimos_free_result ($res);
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
This example will fetch a row.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-fetch-row">
<refnamediv>
<refname>ovrimos_fetch_row</refname>
<refpurpose>Fetches a row from the result set</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>bool <function>ovrimos_fetch_row</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>int
<parameter><optional>how</optional></parameter>
</paramdef>
<paramdef>int
<parameter><optional>row_number</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_fetch_row</function> is used to fetch a row
from the result set.
</para>
<para>
<function>ovrimos_fetch_row</function> fetches a row from the
result set. Column values should be retrieved with other
calls. Returns &true; or &false;.
</para>
<para>
<example>
<title>A fetch row example</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = ovrimos_connect ("remote.host", "8001", "admin", "password");
if ($conn != 0) {
echo "Connection ok!";
$res=ovrimos_exec ($conn, "select table_id, table_name from sys.tables");
if ($res != 0) {
echo "Statement ok!";
if (ovrimos_fetch_row ($res, "First")) {
$table_id = ovrimos_result ($res, 1);
$table_name = ovrimos_result ($res, 2);
echo "table_id=".$table_id.", table_name=".$table_name."\n";
if (ovrimos_fetch_row ($res, "Next")) {
$table_id = ovrimos_result ($res, "table_id");
$table_name = ovrimos_result ($res, "table_name");
echo "table_id=".$table_id.", table_name=".$table_name."\n";
} else {
echo "Next: error\n";
}
} else {
echo "First: error\n";
}
ovrimos_free_result ($res);
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
This will fetch a row and print the result.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-result">
<refnamediv>
<refname>ovrimos_result</refname>
<refpurpose>Retrieves the output column</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_result</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>mixed <parameter>field</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_result</function> is used to retrieve the
output column.
</para>
<para>
<function>ovrimos_result</function> retrieves the output column
specified by 'field', either as a string or as an 1-based index.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-result-all">
<refnamediv>
<refname>ovrimos_result_all</refname>
<refpurpose>
Prints the whole result set as an HTML table
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>bool <function>ovrimos_result_all</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>string
<parameter><optional>format</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_result_all</function> is used to print an HTML
table containing the whole result set.
</para>
<para>
<function>ovrimos_result_all</function> prints the whole result
set as an HTML table. Returns &true; or
&false;.
</para>
<para>
<example>
<title>Prepare a statement, execute, and view the result</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = ovrimos_connect ("db_host", "8001", "admin", "password");
if ($conn != 0) {
echo "Connection ok!";
$res = ovrimos_prepare ($conn, "select table_id, table_name
from sys.tables where table_id = 7");
if ($res != 0) {
echo "Prepare ok!";
if (ovrimos_execute ($res, array(3))) {
echo "Execute ok!\n";
ovrimos_result_all ($res);
} else {
echo "Execute not ok!";
}
ovrimos_free_result ($res);
} else {
echo "Prepare not ok!\n";
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
This will execute an SQL statement and print the result in an
HTML table.
</para>
<para>
<example>
<title>Ovrimos_result_all with meta-information</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = ovrimos_connect ("db_host", "8001", "admin", "password");
if ($conn != 0) {
echo "Connection ok!";
$res = ovrimos_exec ($conn, "select table_id, table_name
from sys.tables where table_id = 1")
if ($res != 0) {
echo "Statement ok! cursor=".ovrimos_cursor ($res)."\n";
$colnb = ovrimos_num_fields ($res);
echo "Output columns=".$colnb."\n";
for ($i=1; $i <= $colnb; $i++) {
$name = ovrimos_field_name ($res, $i);
$type = ovrimos_field_type ($res, $i);
$len = ovrimos_field_len ($res, $i);
echo "Column ".$i." name=".$name." type=".$type." len=".$len."\n";
}
ovrimos_result_all ($res);
ovrimos_free_result ($res);
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>ovrimos_result_all example</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = ovrimos_connect ("db_host", "8001", "admin", "password");
if ($conn != 0) {
echo "Connection ok!";
$res = ovrimos_exec ($conn, "update test set i=5");
if ($res != 0) {
echo "Statement ok!";
echo ovrimos_num_rows ($res)." rows affected\n";
ovrimos_free_result ($res);
}
ovrimos_close($conn);
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-num-rows">
<refnamediv>
<refname>ovrimos_num_rows</refname>
<refpurpose>
Returns the number of rows affected by update operations
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_num_rows</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_num_rows</function> is used to get the number
of rows affected by update operations.
</para>
<para>
<function>ovrimos_num_rows</function> returns the number of rows
affected by update operations.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-num-fields">
<refnamediv>
<refname>ovrimos_num_fields</refname>
<refpurpose>Returns the number of columns</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_num_fields</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_num_fields</function> is used to get the number
of columns.
</para>
<para>
<function>ovrimos_num_fields</function> returns the number of
columns in a result_id resulting from a query.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-field-name">
<refnamediv>
<refname>ovrimos_field_name</refname>
<refpurpose>Returns the output column name</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_field_name</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>int <parameter>field_number</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_field_name</function> is used to get the output
column name.
</para>
<para>
<function>ovrimos_field_name</function> returns the output column
name at the (1-based) index specified.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-field-type">
<refnamediv>
<refname>ovrimos_field_type</refname>
<refpurpose>
Returns the (numeric) type of the output column
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_field_type</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>int <parameter>field_number</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_field_type</function> is used to get the
(numeric) type of the output column.
</para>
<para>
<function>ovrimos_field_type</function> returns the (numeric)
type of the output column at the (1-based) index specified.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-field-len">
<refnamediv>
<refname>ovrimos_field_len</refname>
<refpurpose>Returns the length of the output column</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_field_len</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>int <parameter>field_number</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_field_len</function> is used to get the length
of the output column with number <parameter>field_number</parameter>,
in result <parameter>result_id</parameter>.
</para>
<para>
<function>ovrimos_field_len</function> returns the length of the
output column at the (1-based) index specified.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-field-num">
<refnamediv>
<refname>ovrimos_field_num</refname>
<refpurpose>
Returns the (1-based) index of the output column
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_field_num</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
<paramdef>string <parameter>field_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_field_num</function> is used to get the
(1-based) index of the output column.
</para>
<para>
<function>ovrimos_field_num</function> returns the (1-based)
index of the output column specified by name, or &false;.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-free-result">
<refnamediv>
<refname>ovrimos_free_result</refname>
<refpurpose>Frees the specified result_id</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>bool <function>ovrimos_free_result</function></funcdef>
<paramdef>int <parameter>result_id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_free_result</function> is used to free the
result_id.
</para>
<para>
<function>ovrimos_free_result</function> frees the specified
result_id <parameter>result_id</parameter>. Returns &true;.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-commit">
<refnamediv>
<refname>ovrimos_commit</refname>
<refpurpose>Commits the transaction</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_commit</function></funcdef>
<paramdef>int <parameter>connection_id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_commit</function> is used to commit the
transaction.
</para>
<para>
<function>ovrimos_commit</function> commits the transaction.
</para>
</refsect1>
</refentry>
<refentry id="function.ovrimos-rollback">
<refnamediv>
<refname>ovrimos_rollback</refname>
<refpurpose>Rolls back the transaction</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ovrimos_rollback</function></funcdef>
<paramdef>int <parameter>connection_id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>ovrimos_rollback</function> is used to roll back the
transaction.
</para>
<para>
<function>ovrimos_rollback</function> rolls back the transaction.
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->