fix found bugs and rewrite almost all examples

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@308842 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Esen Sagynov 2011-03-02 07:07:40 +00:00
parent 7913c8c0ce
commit 3c08ec64ae
58 changed files with 2516 additions and 850 deletions

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-affected-rows" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_affected_rows</refname>
<refpurpose>Get number of affected rows in previous Cubrid operation</refpurpose>
<refpurpose>Returns the number of rows affected by the last SQL statement</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,8 @@
<methodparam choice="opt"><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_affected_rows</function> function is used to get the number of rows affected by the SQL sentence (INSERT, DELETE, UPDATE).
The <function>cubrid_affected_rows</function> function is used to get the
number of rows affected by the SQL sentence (INSERT, DELETE, UPDATE).
</para>
</refsect1>
@ -22,10 +23,10 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>req_identifier</parameter></term>
<listitem><para>Request identifier. If the request identifier is not
specified, the last request is assumed.</para></listitem>
<varlistentry>
<term><parameter>req_identifier</parameter></term>
<listitem><para>Request identifier. If the request identifier is not
specified, the last request is assumed.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -52,15 +53,30 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "delete from person where name like 'j%'");
if ($req) {
$row_count = cubrid_affected_rows ($req);
echo $row_count;
cubrid_close_request ($req);
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE cubrid_test");
cubrid_execute($conn, "CREATE TABLE cubrid_test (t varchar)");
for ($i = 0; $i < 5; $i++) {
cubrid_execute($conn, "INSERT INTO cubrid_test(t) VALUES('cubrid_test')");
}
cubrid_execute($conn, "DELETE FROM cubrid_test");
$affected_num = cubrid_affected_rows();
var_dump($affected_num);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(5)
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-bind" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_bind</refname>
<refpurpose>Is used to bind values</refpurpose>
<refpurpose>Binds variables to a prepared statement as parameters</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -25,7 +25,7 @@
<note>
<para>
Known issue: If column data type is CLOB, binding parameter will fail.
This bug will fixed later, better use BLOB now.
This bug will fixed later.
</para>
</note>
<para>
@ -198,23 +198,52 @@
<programlisting role="php">
<![CDATA[
<?php
$con = cubrid_connect("dbsvr.cubrid.com", 12345, "demodb");
if ($con) {
$sql = "insert into tbl values (?,?,?)";
$req = cubrid_prepare($con, $sql, CUBRID_INCLUDE_OID);
$conn = cubrid_connect("localhost", 33000, "demodb");
$i = 0;
while ($i < 2) {
$res = cubrid_bind($req, 1, "1", "NUMBER");
$res = cubrid_bind($req, 2, "2");
$res = cubrid_bind($req, 3, "04:22:34 PM 08/07/2007");
$res = cubrid_execute( $req );
$i = $i + 1;
}
}
$result = cubrid_execute($conn, "SELECT code FROM event WHERE sports='Basketball' and gender='M'");
$row = cubrid_fetch_array($result, CUBRID_ASSOC);
$event_code = $row["code"];
cubrid_close_request($result);
$game_req = cubrid_prepare($conn, "SELECT athlete_code FROM game WHERE host_year=1992 and event_code=? and nation_code='USA'");
cubrid_bind($game_req, 1, $event_code, "number");
cubrid_execute($game_req);
printf("--- Dream Team (1992 United States men's Olympic basketball team) ---\n");
while ($athlete_code = cubrid_fetch_array($game_req, CUBRID_NUM)) {
$athlete_req = cubrid_prepare($conn, "SELECT name FROM athlete WHERE code=? AND nation_code='USA' AND event='Basketball' AND gender='M'");
cubrid_bind($athlete_req, 1, $athlete_code[0], "number");
cubrid_execute($athlete_req);
$row = cubrid_fetch_assoc($athlete_req);
printf("%s\n", $row["name"]);
}
cubrid_close_request($game_req);
cubrid_close_request($athlete_req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
--- Dream Team (1992 United States men's Olympic basketball team) ---
Stockton John
Robinson David
Pippen Scottie
Mullin C.
Malone Karl
Laettner C.
Jordan Michael
Johnson Earvin
Ewing Patrick
Drexler Clyde
Bird Larry
Barkley Charles
]]>
</screen>
</example>
<example>
@ -222,7 +251,7 @@ if ($con) {
<programlisting role="php">
<![CDATA[
<?php
$con = cubrid_connect ("localhost", 33000, "foo");
$con = cubrid_connect("localhost", 33000, "foo");
if ($con) {
$sql = "INSERT INTO php_cubrid_lob_test(doc_content) VALUES(?)";
$req = cubrid_prepare($con, $sql);

View file

@ -14,7 +14,9 @@
<methodparam><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_close_request</function> function closes the request handle given by the <parameter>req_identifier</parameter> argument, and releases the memory region related to the handle.
The <function>cubrid_close_request</function> function closes the request
handle given by the <parameter>req_identifier</parameter> argument, and
releases the memory region related to the handle.
</para>
</refsect1>
@ -47,22 +49,37 @@
<programlisting role="php">
<![CDATA[
<?php
$con = cubrid_connect ("dbsvr.cubrid.com", 12345, "demodb");
if ($con) {
echo "connected successfully";
$req = cubrid_execute ( $con, "select * from members", CUBRID_INCLUDE_OID | CUBRID_ASYNC);
if ($req) {
while ( list ($id, $name) = cubrid_fetch ($req) ){
echo $id;
echo $name;
}
cubrid_close_request($req);
}
cubrid_disconnect($con);
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_prepare ($conn, "SELECT * FROM olympic WHERE host_year=?");
$host_year = 2004;
cubrid_bind($req, 1, $host_year, "number");
cubrid_execute($req);
printf("%-9s %-11s %-9s %-12s %-12s %-15s %-15s\n",
"host_year", "host_nation", "host_city", "opening_date",
"closing_date", "mascot", "slogan");
while ($row = cubrid_fetch_assoc($req)) {
printf("%-9s %-11s %-9s %-12s %-12s %-15s %-15s\n",
$row["host_year"], $row["host_nation"], $row["host_city"],
$row["opening_date"], $row["closing_date"], $row["mascot"], $row["slogan"]);
}
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
host_year host_nation host_city opening_date closing_date mascot slogan
2004 Greece Athens 2004-8-13 2004-8-29 Athena Phevos Welcome Home
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-col-get" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_col_get</refname>
<refpurpose>Is used to get contents of the elements</refpurpose>
<refpurpose>Get contents of collection type column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -16,7 +16,9 @@
<methodparam><type>string</type><parameter>attr_name</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_col_get</function> function is used to get contents of the elements of the collection type (set, multiset, sequence) attribute you requested as an array.
The <function>cubrid_col_get</function> function is used to get contents
of the elements of the collection type (set, multiset, sequence) attribute
you requested as an array.
</para>
</refsect1>
@ -30,7 +32,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance that you want to read.</para></listitem>
<listitem><para>OID of the instance that you want to read.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr_name</parameter></term>
@ -39,15 +41,18 @@
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Array (0-based numerical array) containing the elements you requested, when process is successful;
Array (0-based numerical array) containing the elements you requested,
when process is successful;
</para>
<para>
&false; (to distinguish the error from the situation of attribute having empty collection or NULL, in case of error, a warning message is shown; in such case you can check the error by using <function>cubrid_error_code</function>), when process is unsuccessful.
&false; (to distinguish the error from the situation of attribute having
empty collection or NULL, in case of error, a warning message is shown; in
such case you can check the error by using
<function>cubrid_error_code</function>), when process is unsuccessful.
</para>
</refsect1>
@ -58,17 +63,44 @@
<programlisting role="php">
<![CDATA[
<?php
$elem_array = cubrid_col_get ($con, $oid, "tel");
while (list ($key, $val) = each ($elem_array)) {
echo "tel: $val\n";
}
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
$size = cubrid_col_size($conn, $oid, "b");
var_dump($size);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
int(3)
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-col-size" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_col_size</refname>
<refpurpose>Is used to get the number of elements</refpurpose>
<refpurpose>Get the number of elements in collection type column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -16,7 +16,9 @@
<methodparam><type>string</type><parameter>attr_name</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_col_size</function> function is used to get the number of elements in a collection type (set, multiset, sequence) attribute.
The <function>cubrid_col_size</function> function is used to get the
number of elements in a collection type (set, multiset, sequence)
attribute.
</para>
</refsect1>
@ -30,7 +32,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid the instance that you want to work with.</para></listitem>
<listitem><para>OID the instance that you want to work with.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr_name</parameter></term>
@ -81,15 +83,44 @@
<programlisting role="php">
<![CDATA[
<?php
$elem_count = cubrid_col_size ($con, $oid, "tel");
echo "$oid (tel) has $elem_count elements\n";
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
$size = cubrid_col_size($conn, $oid, "b");
var_dump($size);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
int(3)
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-column-names" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_column_names</refname>
<refpurpose>Is used to get the column names </refpurpose>
<refpurpose>Get the column names in result</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,8 @@
<methodparam><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_column_names</function> function is used to get the column names of the query result by using <parameter>req_identifier</parameter>.
The <function>cubrid_column_names</function> function is used to get the
column names of the query result by using <parameter>req_identifier</parameter>.
</para>
</refsect1>
@ -47,19 +48,35 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "select * from person");
if ($req) {
$coltypes = cubrid_column_types ($req);
$colnames = cubrid_column_names ($req);
while (list ($key, $coltype) = each ($coltypes))
echo $coltype;
while (list ($key, $colname) = each ($colnames))
echo $colname;
cubrid_close_request ($req);
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM game WHERE host_year=2004 AND nation_code='AUS' AND medal='G'");
$column_names = cubrid_column_names($result);
$column_types = cubrid_column_types($result);
printf("%-30s %-30s %-15s\n", "Column Names", "Column Types", "Column Maxlen");
for($i = 0, $size = count($column_names); $i < $size; $i++) {
$column_len = cubrid_field_len($result, $i);
printf("%-30s %-30s %-15s\n", $column_names[$i], $column_types[$i], $column_len);
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Column Names Column Types Column Maxlen
host_year integer 11
event_code integer 11
athlete_code integer 11
stadium_code integer 11
nation_code char(3) 3
medal char(1) 1
game_date date 10
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-column-types" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_column_types</refname>
<refpurpose>Gets column types </refpurpose>
<refpurpose>Gets column types in result</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,8 @@
<methodparam><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_column_types</function> function gets column types of query results by using <parameter>req_identifier</parameter>.
The <function>cubrid_column_types</function> function gets column types of
query results by using <parameter>req_identifier</parameter>.
</para>
</refsect1>
@ -22,9 +23,9 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>req_identifier</parameter></term>
<listitem><para>Request identifier.</para></listitem>
<varlistentry>
<term><parameter>req_identifier</parameter></term>
<listitem><para>Request identifier.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -47,19 +48,35 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "select * from person");
if ($req) {
$coltypes = cubrid_column_types ($req);
$colnames = cubrid_column_names ($req);
while (list ($key, $coltype) = each ($coltypes))
echo $coltype;
while (list ($key, $colname) = each ($colnames))
echo $colname;
cubrid_close_request ($req);
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM game WHERE host_year=2004 AND nation_code='AUS' AND medal='G'");
$column_names = cubrid_column_names($result);
$column_types = cubrid_column_types($result);
printf("%-30s %-30s %-15s\n", "Column Names", "Column Types", "Column Maxlen");
for($i = 0, $size = count($column_names); $i < $size; $i++) {
$column_len = cubrid_field_len($result, $i);
printf("%-30s %-30s %-15s\n", $column_names[$i], $column_types[$i], $column_len);
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Column Names Column Types Column Maxlen
host_year integer 11
event_code integer 11
athlete_code integer 11
stadium_code integer 11
nation_code char(3) 3
medal char(1) 1
game_date date 10
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-commit" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_commit</refname>
<refpurpose>Is used to execute commit on the transaction</refpurpose>
<refpurpose>Commits a transaction</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -13,7 +13,17 @@
<type>bool</type><methodname>cubrid_commit</methodname>
<methodparam><type>resource</type><parameter>conn_identifier</parameter></methodparam> </methodsynopsis>
<para>
The <function>cubrid_commit</function> function is used to execute commit on the transaction pointed by <parameter>conn_handle</parameter>, currently on progress. Connection to the server is closed after the <function>cubrid_commit</function> function is called; the connection handle is still valid, however.
The <function>cubrid_commit</function> function is used to execute commit
on the transaction pointed by <parameter>conn_identifier</parameter>,
currently on progress. Connection to the server is closed after the
<function>cubrid_commit</function> function is called; the connection
handle is still valid, however.
</para>
<para>
In CUBRID PHP, an auto-commit mode is disabled by default for transaction
management, and it can't be enabled in current version CUBRID PHP. It can
be set in next version. And auto commit modes can be applied only for
SELECT statements by setting broker parameters.
</para>
</refsect1>
@ -46,18 +56,72 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($oid, "insert into person values (2,John)");
if ($req) {
cubrid_close_request ($req);
if ($failed) {
cubrid_rollback ($con);
} else {
cubrid_commit ($con);
}
$conn = cubrid_connect("127.0.0.1", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE publishers");
$sql = <<<EOD
CREATE TABLE publishers(
pub_id CHAR(3),
pub_name VARCHAR(20),
city VARCHAR(15),
state CHAR(2),
country VARCHAR(15)
)
EOD;
if (!cubrid_execute($conn, $sql)) {
printf("Error facility: %d\nError code: %d\nError msg: %s\n", cubrid_error_code_facility(), cubrid_error_code(), cubrid_error_msg());
cubrid_disconnect($conn);
exit;
}
$req = cubrid_prepare($conn, "INSERT INTO publishers VALUES(?, ?, ?, ?, ?)");
$id_list = array("P01", "P02", "P03", "P04");
$name_list = array("Abatis Publishers", "Core Dump Books", "Schadenfreude Press", "Tenterhooks Press");
$city_list = array("New York", "San Francisco", "Hamburg", "Berkeley");
$state_list = array("NY", "CA", NULL, "CA");
$country_list = array("USA", "USA", "Germany", "USA");
for ($i = 0, $size = count($id_list); $i < $size; $i++) {
cubrid_bind($req, 1, $id_list[$i]);
cubrid_bind($req, 2, $name_list[$i]);
cubrid_bind($req, 3, $city_list[$i]);
cubrid_bind($req, 4, $state_list[$i]);
cubrid_bind($req, 5, $country_list[$i]);
if (!($ret = cubrid_execute($req))) {
break;
}
}
if (!$ret) {
cubrid_rollback($conn);
} else {
cubrid_commit($conn);
$req = cubrid_execute($conn, "SELECT * FROM publishers");
while ($result = cubrid_fetch_assoc($req)) {
printf("%-3s %-20s %-15s %-3s %-15s\n",
$result["pub_id"], $result["pub_name"], $result["city"], $result["state"], $result["country"]);
}
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
P01 Abatis Publishers New York NY USA
P02 Core Dump Books San Francisco CA USA
P03 Schadenfreude Press Hamburg Germany
P04 Tenterhooks Press Berkeley CA USA
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-connect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_connect</refname>
<refpurpose>Is used to establish the environment for connecting to your server </refpurpose>
<refpurpose>Open a connection to a CUBRID Server</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -18,7 +18,11 @@
<methodparam choice="opt"><type>string</type><parameter>passwd</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_connect</function> function is used to establish the environment for connecting to your server by using your server address, port number, database name, user name, and password. If the user name and password is not given, then the "PUBLIC" connection will be made by default.
The <function>cubrid_connect</function> function is used to establish the
environment for connecting to your server by using your server address,
port number, database name, user name, and password. If the user name and
password is not given, then the "PUBLIC" connection will be made by
default.
</para>
</refsect1>
@ -28,11 +32,11 @@
<variablelist>
<varlistentry>
<term><parameter>host</parameter></term>
<listitem><para>Host name or IP address of CAS server.</para></listitem>
<listitem><para>Host name or IP address of CUBRID CAS server.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>port</parameter></term>
<listitem><para>Port number of CAS server (BROKER_PORT configured in $CUBRID/conf/cubrid_broker.conf).</para></listitem>
<listitem><para>Port number of CUBRID CAS server (BROKER_PORT configured in $CUBRID/conf/cubrid_broker.conf).</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>dbname</parameter></term>
@ -67,23 +71,56 @@
<programlisting role="php">
<![CDATA[
<?php
$con = cubrid_connect ("210.211.133.100", 12345, "demodb");
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
if ($con) {
echo "connected successfully";
$req =cubrid_execute($con, "insert into person values(1,James)");
printf("\n");
if ($req) {
cubrid_close_request ($req);
cubrid_commit ($con);
} else {
cubrid_rollback ($con);
}
cubrid_disconnect ($con);
$conn = cubrid_connect("localhost", 33000, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
CUBRID PHP Version: 8.3.1.0005
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT -1
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.3.1.0173
Client Info: 8.3.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>
</refsect1>
@ -91,6 +128,7 @@ if ($con) {
&reftitle.seealso;
<para>
<simplelist>
<member><function>cubrid_connect_with_url</function></member>
<member><function>cubrid_disconnect</function></member>
</simplelist>
</para>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-current-oid" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_current_oid</refname>
<refpurpose>Is used to get the oid of the current cursor location</refpurpose>
<refpurpose>Get OID of the current cursor location</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,11 @@
<methodparam><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_current_oid</function> function is used to get the oid of the current cursor location from the query result. To use <function>cubrid_current_oid</function>, the query executed must be a updatable query, and the CUBRID_INCLUDE_OID option must be included during the query execution.
The <function>cubrid_current_oid</function> function is used to get the
oid of the current cursor location from the query result. To use
<function>cubrid_current_oid</function>, the query executed must be a
updatable query, and the CUBRID_INCLUDE_OID option must be included during
the query execution.
</para>
</refsect1>
@ -22,9 +26,9 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>req_identifier</parameter></term>
<listitem><para>Request identifier.</para></listitem>
<varlistentry>
<term><parameter>req_identifier</parameter></term>
<listitem><para>Request identifier.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -47,17 +51,29 @@
<programlisting role="php">
<![CDATA[
<?php
$req =cubrid_execute($con,"select * from person where id =1",
CUBRID_INCLUDE_OID);
if ($req) {
cubrid_fetch ($req);
$oid = cubrid_current_oid ($req);
cubrid_close_request ($req);
echo "OID is $oid";
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM code", CUBRID_INCLUDE_OID);
$oid = cubrid_current_oid($req);
$res = cubrid_get($conn, $oid);
print_r($res);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[s_name] => X
[f_name] => Mixed
)
]]>
</screen>
</example>
</refsect1>

View file

@ -15,7 +15,11 @@
<methodparam><type>int</type><parameter>row_number</parameter></methodparam>
</methodsynopsis>
<para>
This function performs the moving of the internal row pointer of the CUBRID result (associated with the specified result identifier) to point to a specific row number. There are functions, such as <function>cubrid_fetch_assoc</function>, which use the current stored value of <parameter>row number</parameter>.
This function performs the moving of the internal row pointer of the
CUBRID result (associated with the specified result identifier) to point
to a specific row number. There are functions, such as
<function>cubrid_fetch_assoc</function>, which use the current stored
value of <parameter>row number</parameter>.
</para>
</refsect1>
@ -55,37 +59,48 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
echo "seek to row 0 and fetching fields: ";
cubrid_data_seek($result, 0);
$row = cubrid_fetch_assoc($result);
echo $row["name"]."|". $row["address"]."|".$row["salary"]."<br>";
$conn = cubrid_connect("127.0.0.1", 33000, "demodb");
echo "seek to row 2 and fetching fields: ";
cubrid_data_seek($result, 2);
$row = cubrid_fetch_assoc($result);
echo $row["name"]."|". $row["address"]."|".$row["salary"]."<br>";
$req = cubrid_execute($conn, "SELECT * FROM code");
cubrid_data_seek($req, 0);
cubrid_close_request($result);
}
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_data_seek($req, 2);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_data_seek($req, 4);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
seek to row 0 and fetching fields: Peter|1st Avenue, New York|1000.0000000000000000
seek to row 2 and fetching fields: Peter Norton|81254, CA|19834.0000000000000000
array(2) {
[0]=>
string(1) "X"
[1]=>
string(5) "Mixed"
}
array(2) {
[0]=>
string(1) "M"
[1]=>
string(3) "Man"
}
array(2) {
[0]=>
string(1) "S"
[1]=>
string(6) "Silver"
}
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-disconnect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_disconnect</refname>
<refpurpose>Ends the transaction currently on process</refpurpose>
<refpurpose>Closes a database connection</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -13,9 +13,11 @@
<type>bool</type><methodname>cubrid_disconnect</methodname>
<methodparam><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_disconnect</function> function ends the transaction currently on process, closes the connection handle and disconnects from server. If there exists any request handle not closed yet at this point, it will be closed.
</para>
<para>
The <function>cubrid_disconnect</function> function closes the connection
handle and disconnects from server. If there exists any request handle not
closed yet at this point, it will be closed.
</para>
</refsect1>
<refsect1 role="parameters">
@ -47,25 +49,60 @@
<programlisting role="php">
<![CDATA[
<?php
$con = cubrid_connect ("210.211.133.100", 12345, "demodb");
if ($con) {
echo "connected successfully";
$req = cubrid_execute ( $con, "insert into person values(1,James)");
if ($req) {
cubrid_close_request ($req);
cubrid_commit ($con);
} else {
cubrid_rollback ($con);
}
cubrid_disconnect ($con);
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
printf("\n");
$conn = cubrid_connect("localhost", 33000, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
CUBRID PHP Version: 8.3.1.0005
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT -1
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.3.1.0173
Client Info: 8.3.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-drop" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_drop</refname>
<refpurpose>Is used to delete an instance </refpurpose>
<refpurpose>Delete an instance using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,8 @@
<methodparam><type>string</type><parameter>oid</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_drop</function> function is used to delete an instance from database by using <parameter>oid</parameter>.
The <function>cubrid_drop</function> function is used to delete an
instance from database by using <parameter>oid</parameter>.
</para>
</refsect1>
@ -52,16 +53,104 @@
<programlisting role="php">
<![CDATA[
<?php
$deloid = cubrid_get ($con, $oid, "order");
$res = cubrid_drop ($con, $deloid);
if ($res) {
cubrid_commit ($con);
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(2, {4,5,7}, {44,55,66,666}, 'b')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
printf("--- Before Drop: ---\n");
$attr = cubrid_get($conn, $oid);
var_dump($attr);
if (cubrid_drop($conn, $oid)) {
cubrid_commit($conn);
} else {
cubrid_rollback ($con);
cubrid_rollback($conn);
}
cubrid_close_request($req);
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
printf("\n--- After Drop: ---\n");
$attr = cubrid_get($conn, $oid);
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
--- Before Drop: ---
array(4) {
["a"]=>
string(1) "1"
["b"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
["c"]=>
array(4) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
}
["d"]=>
string(10) "a "
}
--- After Drop: ---
array(4) {
["a"]=>
string(1) "2"
["b"]=>
array(3) {
[0]=>
string(1) "4"
[1]=>
string(1) "5"
[2]=>
string(1) "7"
}
["c"]=>
array(4) {
[0]=>
string(2) "44"
[1]=>
string(2) "55"
[2]=>
string(2) "66"
[3]=>
string(3) "666"
}
["d"]=>
string(10) "b "
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-error-code-facility" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_error_code_facility</refname>
<refpurpose>Is used to get the facility code</refpurpose>
<refpurpose>Get the facility code of error</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,10 @@
<void />
</methodsynopsis>
<para>
The <function>cubrid_error_code_facility</function> function is used to get the facility code (level in which the error occurred) from the error code of the error that occurred during the API execution. Usually, you can get the error code when API returns false as its return value.
The <function>cubrid_error_code_facility</function> function is used to
get the facility code (level in which the error occurred) from the error
code of the error that occurred during the API execution. Usually, you can
get the error code when API returns false as its return value.
</para>
</refsect1>
@ -38,18 +41,27 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "select id, name from person");
if ($req) {
while (list ($id, $name) = cubrid_fetch($req))
echo $id, $name;
} else {
echo "Error Code: ", cubrid_error_code ();
echo "Error Facility: ", cubrid_error_code_facility ();
echo "Error Message: ", cubrid_error_msg ();
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = @cubrid_execute($conn, "SELECT * FROM unknown");
if (!$req) {
printf("Error facility: %d\nError code: %d\nError msg: %s\n",
cubrid_error_code_facility(), cubrid_error_code(), cubrid_error_msg());
cubrid_disconnect($conn);
exit;
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Error facility: 1
Error code: -493
Error msg: Syntax: syntax error, unexpected UNKNOWN
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-error-code" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_error_code</refname>
<refpurpose>Is used to get the error code </refpurpose>
<refpurpose>Get error code for the most recent function call</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,9 @@
<void />
</methodsynopsis>
<para>
The <function>cubrid_error_code</function> function is used to get the error code of the error that occurred during the API execution. Usually, it gets the error code when API returns false as its return value.
The <function>cubrid_error_code</function> function is used to get the
error code of the error that occurred during the API execution. Usually,
it gets the error code when API returns false as its return value.
</para>
</refsect1>
@ -39,18 +41,28 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "select id, name from person");
if ($req) {
while (list ($id, $name) = cubrid_fetch($req))
echo $id, $name;
} else {
echo "Error Code: ", cubrid_error_code ();
echo "Error Facility: ", cubrid_error_code_facility ();
echo "Error Message: ", cubrid_error_msg ();
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_prepare($conn , "SELECT * FROM code WHERE s_name=?");
$req = @cubrid_execute($req);
if (!$req) {
printf("Error facility: %d\nError code: %d\nError msg: %s\n",
cubrid_error_code_facility(), cubrid_error_code(), cubrid_error_msg());
cubrid_disconnect($conn);
exit;
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Error facility: 4
Error code: -2015
Error msg: Some parameter not binded
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-error-msg" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_error_msg</refname>
<refpurpose>Is used to get the error message</refpurpose>
<refpurpose>Get last error message for the most recent function call</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,9 @@
<void />
</methodsynopsis>
<para>
The <function>cubrid_error_msg</function> function is used to get the error message that occurred during the use of CUBRID API. Usually, it gets error message when API returns false as its return value.
The <function>cubrid_error_msg</function> function is used to get the
error message that occurred during the use of CUBRID API. Usually, it gets
error message when API returns false as its return value.
</para>
</refsect1>
@ -38,18 +40,27 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "select id, name from person");
if ($req) {
while (list ($id, $name) = cubrid_fetch($req))
echo $id, $name;
} else {
echo "Error Code: ", cubrid_error_code ();
echo "Error Facility: ", cubrid_error_code_facility ();
echo "Error Message: ", cubrid_error_msg ();
$conn = cubrid_connect("localhost", 33000, "demodb");
if (!@cubrid_schema($conn, 100000)) {
printf("Error facility: %d\nError code: %d\nError msg: %s\n",
cubrid_error_code_facility(), cubrid_error_code(), cubrid_error_msg());
cubrid_disconnect($conn);
exit;
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Error facility: 2
Error code: -1015
Error msg: Invalid T_CCI_SCH_TYPE value
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-execute" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_execute</refname>
<refpurpose>Is used to execute the given SQL sentence.</refpurpose>
<refpurpose>Executes a prepared SQL statement</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,19 +15,35 @@
<methodparam><type>string</type><parameter>SQL</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>option</parameter></methodparam>
</methodsynopsis>
<methodsynopsis>
<methodsynopsis>
<type>bool</type><methodname>cubrid_execute</methodname>
<methodparam><type>resource</type><parameter>request_identifier</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>option</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_execute</function> function is used to execute the given SQL sentence. It executes the query by using <parameter>conn_identifier</parameter> and SQL, and then returns the request identifier created. It is used for simple execution of query, where the parameter binding is not needed. In addition, the <function>cubrid_execute</function> function is used to execute the prepared statement by means of <function>cubrid_prepare</function> and <function>cubrid_bind</function>. At this time, you need to specify arguments of <parameter>request_identifier</parameter> and <parameter>option</parameter>.
The <function>cubrid_execute</function> function is used to execute
the given SQL sentence. It executes the query by using
<parameter>conn_identifier</parameter> and SQL, and then returns the
request identifier created. It is used for simple execution of query,
where the parameter binding is not needed. In addition, the
<function>cubrid_execute</function> function is used to execute the
prepared statement by means of <function>cubrid_prepare</function> and
<function>cubrid_bind</function>. At this time, you need to specify
arguments of <parameter>request_identifier</parameter> and
<parameter>option</parameter>.
</para>
<para>
You can use the <parameter>option</parameter> argument to tell whether to receive oid of the row after the execution, and, whether to execute the query in asynchronous mode. You can use it by setting the CUBRID_INCLUDE_OID and CUBRID_ASYNC using bitwise or operator. If the both variables are not explicitly given, they are not selected by default.
You can use the <parameter>option</parameter> argument to tell whether
to receive oid of the row after the execution, and, whether to execute
the query in asynchronous mode. You can use it by setting the
CUBRID_INCLUDE_OID and CUBRID_ASYNC using bitwise or operator. If the
both variables are not explicitly given, they are not selected by
default.
</para>
<para>
If the first argument is <parameter>request_identifier</parameter> to execute the <function>cubrid_prepare</function> function, you can specify an option, CUBRID_ASYNC only.
If the first argument is <parameter>request_identifier</parameter> to
execute the <function>cubrid_prepare</function> function, you can
specify an option, CUBRID_ASYNC only.
</para>
</refsect1>
@ -58,7 +74,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Request identifier, when process is successful and first param is conn_identifier; &true;, when process is successful and first argument is request_identifier.
Request identifier, when process is successful and first param is
conn_identifier; &true;, when process is successful and first argument is
request_identifier.
</para>
<para>
&false;, when process is unsuccessful.
@ -72,39 +90,37 @@
<programlisting role="php">
<![CDATA[
<?php
$con = cubrid_connect ("dbsvr.cubrid.com", 33000, "demodb");
if ($con) {
echo "connected successfully";
$req = cubrid_execute ($con, "select * from members", CUBRID_INCLUDE_OID | CUBRID_ASYNC);
if ($req) {
while (list ($id, $name) = cubrid_fetch ($req)) {
echo $id;
echo $name;
}
cubrid_close_request ($req);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
cubrid_disconnect ($con);
}
$con = cubrid_connect ("dbsvr.cubrid.com", 33000, "demodb");
if ($con) {
echo "connected successfully";
$sql = "insert into tbl values (?, ?, ?)";
$req = cubrid_prepare($con, $sql, CUBRID_INCLUDE_OID);
$result = cubrid_execute($conn, "SELECT code FROM event WHERE name='100m Butterfly' and gender='M'", CUBRID_ASYNC);
$row = cubrid_fetch_array($result, CUBRID_ASSOC);
$event_code = $row["code"];
$i = 0;
while ( $i < 2 ) {
$res = cubrid_bind($req, 1, "1", "NUMBER");
$res = cubrid_bind($req, 2, "2");
$res = cubrid_bind($req, 3, "04:22:34 PM 08/07/2007");
$res = cubrid_execute($req);
$i = $i + 1;
}
cubrid_close_request($result);
$history_req = cubrid_prepare($conn, "SELECT * FROM history WHERE event_code=?");
cubrid_bind($history_req, 1, $event_code, "number");
cubrid_execute($history_req);
printf("%-20s %-9s %-10s %-5s\n", "athlete", "host_year", "score", "unit");
while ($row = cubrid_fetch_array($history_req, CUBRID_ASSOC)) {
printf("%-20s %-9s %-10s %-5s\n",
$row["athlete"], $row["host_year"], $row["score"], $row["unit"]);
}
cubrid_close_request($history_req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
athlete host_year score unit
Phelps Michael 2004 51.25 time
]]>
</screen>
</example>
</refsect1>

View file

@ -56,25 +56,36 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute($con, "select * from members", CUBRID_INCLUDE_OID | CUBRID_ASYNC);
if ($req) {
while (list($id, $name) = cubrid_fetch_array($req)){
echo $id;
echo $name;
}
cubrid_close_request($req);
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT name,area,seats,address FROM stadium WHERE nation_code='GRE' AND seats > 10000");
printf("%-40s %-10s %-6s %-20s\n", "name", "area", "seats", "address");
while ($row = cubrid_fetch_array($req, CUBRID_NUM)) {
printf("%-40s %-10s %-6s %-20s\n", $row[0], $row[1], $row[2], $row[3]);
}
$req = cubrid_execute($con, "select * from teams");
if ($req) {
while($row = cubrid_fetch_array($req, CUBRID_ASSOC)) {
echo $row["id"];
echo $row["name"];
}
}
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
name area seats address
Panathinaiko Stadium 86300.00 50000 Athens, Greece
Olympic Stadium 54700.00 13000 Athens, Greece
Olympic Indoor Hall 34100.00 18800 Athens, Greece
Olympic Hall 52400.00 21000 Athens, Greece
Olympic Aquatic Centre 42500.00 11500 Athens, Greece
Markopoulo Olympic Equestrian Centre 64000.00 15000 Markopoulo, Athens, Greece
Faliro Coastal Zone Olympic Complex 34650.00 12171 Faliro, Athens, Greece
Athens Olympic Stadium 120400.00 71030 Maroussi, Athens, Greece
Ano Liossia 34000.00 12000 Ano Liosia, Athens, Greece
]]>
</screen>
</example>
</refsect1>

View file

@ -14,7 +14,9 @@
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the associative array, that corresponds to the fetched row and, then, moves the internal data pointer ahead, or it returns FALSE when the end is reached.
This function returns the associative array, that corresponds to the
fetched row, and then moves the internal data pointer ahead, or returns
FALSE when the end is reached.
</para>
</refsect1>
@ -47,36 +49,34 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
echo "seek to row 0 and fetching fields: ";
cubrid_data_seek($result, 0);
$row = cubrid_fetch_assoc($result);
echo $row["name"]."|". $row["address"]."|".$row["salary"]."<br>";
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT name,area,seats,address FROM stadium WHERE nation_code='GRE' AND seats > 10000");
echo "seek to row 2 and fetching fields: ";
cubrid_data_seek($result, 2);
$row = cubrid_fetch_assoc($result);
echo $row["name"]."|". $row["address"]."|".$row["salary"]."<br>";
printf("%-40s %-10s %-6s %-20s\n", "name", "area", "seats", "address");
while ($row = cubrid_fetch_assoc($req)) {
printf("%-40s %-10s %-6s %-20s\n",
$row["name"], $row["area"], $row["seats"], $row["address"]);
}
cubrid_close_request($result);
}
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
seek to row 0 and fetching fields: Peter|1st Avenue, New York|1000.0000000000000000
seek to row 2 and fetching fields: Peter Norton|81254, CA|19834.0000000000000000
name area seats address
Panathinaiko Stadium 86300.00 50000 Athens, Greece
Olympic Stadium 54700.00 13000 Athens, Greece
Olympic Indoor Hall 34100.00 18800 Athens, Greece
Olympic Hall 52400.00 21000 Athens, Greece
Olympic Aquatic Centre 42500.00 11500 Athens, Greece
Markopoulo Olympic Equestrian Centre 64000.00 15000 Markopoulo, Athens, Greece
Faliro Coastal Zone Olympic Complex 34650.00 12171 Faliro, Athens, Greece
Athens Olympic Stadium 120400.00 71030 Maroussi, Athens, Greece
Ano Liossia 34000.00 12000 Ano Liosia, Athens, Greece
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-fetch-field" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_fetch_field</refname>
<refpurpose>Returns an object with certain properties</refpurpose>
<refpurpose>Get column information from a result and return as an object</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,8 @@
<methodparam choice="opt"><type>int</type><parameter>field_offset</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
This function returns an object with certain properties of the specific column. The properties of the object are:
This function returns an object with certain properties of the specific
column. The properties of the object are:
</para>
<para>
<variablelist>
@ -48,7 +49,7 @@
<listitem><para>1 if the column is a non-unique key</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>numeri</parameter></term>
<term><parameter>numeric</parameter></term>
<listitem><para>1 if the column is numeric</para></listitem>
</varlistentry>
<varlistentry>
@ -69,8 +70,12 @@
<listitem><para><parameter>result</parameter> comes from a call to <function>cubrid_execute</function></para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>The numerical field offset. If the field offset is not specified, the next field (that was not yet retrieved by this function) is retrieved. The <parameter>field_offset</parameter> starts at 0.</para></listitem>
<term><parameter>field_offset</parameter></term>
<listitem><para>
The numerical field offset. If the field offset is not specified, the
next field (that was not yet retrieved by this function) is retrieved.
The <parameter>field_offset</parameter> starts at 0.
</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -93,51 +98,55 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
echo "Fetching column 0 fields: ";
$meta = cubrid_fetch_field($result, 0);
if (!$meta)
{
echo "No information available<br />\n";
}
echo "<pre>
max_length: $meta->max_length
multiple_key: $meta->multiple_key
name: $meta->name
not_null: $meta->not_null
numeric: $meta->numeric
table: $meta->table
type: $meta->type
default: $meta->def
unique_key: $meta->unique_key
</pre>";
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT event_code,athlete_code,nation_code,game_date FROM game WHERE host_year=1988 and event_code=20001;");
var_dump(cubrid_fetch_row($req));
cubrid_field_seek($req, 1);
$field = cubrid_fetch_field($req);
printf("\n--- Field Properties ---\n");
printf("%-30s %s\n", "name:", $field->name);
printf("%-30s %s\n", "table:", $field->table);
printf("%-30s \"%s\"\n", "default value:", $field->def);
printf("%-30s %d\n", "max lenght:", $field->max_length);
printf("%-30s %d\n", "not null:", $field->not_null);
printf("%-30s %d\n", "unique key:", $field->unique_key);
printf("%-30s %d\n", "multiple key:", $field->multiple_key);
printf("%-30s %d\n", "numeric:", $field->numeric);
printf("%-30s %s\n", "type:", $field->type);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Fetching column 0 fields:
max_length: 13
multiple_key: 1
name: name
not_null: 1
numeric: 0
table: employees
type: STRING
default: [noname]
unique_key: 0
array(4) {
[0]=>
string(5) "20001"
[1]=>
string(5) "16681"
[2]=>
string(3) "KOR"
[3]=>
string(9) "1988-9-30"
}
--- Field Properties ---
name: athlete_code
table: game
default value: ""
max lenght: 5
not null: 1
unique key: 1
multiple key: 0
numeric: 1
type: integer
]]>
</screen>
</example>

View file

@ -14,11 +14,14 @@
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
This function returns an numeric array with the lengths of the values of each field from the current row of the result set or it returns FALSE on failure.
This function returns an numeric array with the lengths of the values of
each field from the current row of the result set or it returns FALSE on
failure.
</para>
<note>
<para>
If field data type is BLOB/CLOB, you should get its length by using <function>cubrid_lob_size</function>.
If field data type is BLOB/CLOB, you should get its length by using
<function>cubrid_lob_size</function>.
</para>
</note>
@ -53,31 +56,42 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
$row= cubrid_fetch_assoc($result);
$lengths = cubrid_fetch_lengths($result);
print_r($row);
echo "<br>";
print_r($lengths);
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM game WHERE host_year=2004 AND nation_code='AUS' AND medal='G'");
$row = cubrid_fetch_row($result);
print_r($row);
$lens = cubrid_fetch_lengths($result);
print_r($lens);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Array ( [name] => Peter [address] => 1st Avenue, New York [salary] => 1000.0000000000000000 )
Array ( [0] => 5 [1] => 20 [2] => 21 )
Array
(
[0] => 2004
[1] => 20085
[2] => 15118
[3] => 30134
[4] => AUS
[5] => G
[6] => 2004-8-20
)
Array
(
[0] => 4
[1] => 5
[2] => 5
[3] => 5
[4] => 3
[5] => 1
[6] => 9
)
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-fetch-object" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_fetch_object</refname>
<refpurpose>Returns an object with the column names</refpurpose>
<refpurpose>Fetches the next row and returns it as an object</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -16,7 +16,9 @@
<methodparam choice="opt"><type>array</type><parameter>params</parameter></methodparam>
</methodsynopsis>
<para>
This function returns an object with the column names of the result set as properties. The values of these properties are extracted from the current row of the result.
This function returns an object with the column names of the result set as
properties. The values of these properties are extracted from the current
row of the result.
</para>
</refsect1>
@ -67,32 +69,64 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
$row = cubrid_fetch_object($result);
echo $row->name."<BR>";
echo $row->address."<BR>";
echo $row->salary;
cubrid_close_request($result);
$conn = cubrid_connect("localhost", 33000, "demodb");
$res = cubrid_execute($conn, "SELECT * FROM code");
var_dump(cubrid_fetch_object($res));
class demodb_code {
public $s_name = null;
public $f_name = null;
public function toString() {
var_dump($this);
}
}
var_dump(cubrid_fetch_object($res, "demodb_code"));
class demodb_code_construct extends demodb_code {
public function __construct($s, $f) {
$this->s_name = $s;
$this->f_name = $f;
}
}
var_dump(cubrid_fetch_object($res, 'demodb_code_construct', array('s_name', 'f_name')));
var_dump(cubrid_fetch_object($res));
cubrid_close_request($res);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Peter
1st Avenue, New York
1000.0000000000000000
object(stdClass)#1 (2) {
["s_name"]=>
string(1) "X"
["f_name"]=>
string(5) "Mixed"
}
object(demodb_code)#1 (2) {
["s_name"]=>
string(1) "W"
["f_name"]=>
string(5) "Woman"
}
object(demodb_code_construct)#1 (2) {
["s_name"]=>
string(6) "s_name"
["f_name"]=>
string(6) "f_name"
}
object(stdClass)#1 (2) {
["s_name"]=>
string(1) "B"
["f_name"]=>
string(6) "Bronze"
}
]]>
</screen>
</example>

View file

@ -14,7 +14,9 @@
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
This function returns a numerical array with the values of the current row from the result set, starting from 0.
This function returns a numerical array with the values of the current row
from the result set, starting from 0, and moves the internal data pointer
ahead.
</para>
</refsect1>
@ -47,31 +49,33 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
$row = cubrid_fetch_row($result);
echo $row[0]."<BR>".$row[1]."<BR>".$row[2]."<BR>";
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT name,area,seats,address FROM stadium WHERE nation_code='GRE' AND seats > 10000");
cubrid_close_request($result);
}
printf("%-40s %-10s %-6s %-20s\n", "name", "area", "seats", "address");
while ($row = cubrid_fetch_row($req)) {
printf("%-40s %-10s %-6s %-20s\n", $row[0], $row[1], $row[2], $row[3]);
}
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Peter
1st Avenue, New York
1000.0000000000000000
name area seats address
Panathinaiko Stadium 86300.00 50000 Athens, Greece
Olympic Stadium 54700.00 13000 Athens, Greece
Olympic Indoor Hall 34100.00 18800 Athens, Greece
Olympic Hall 52400.00 21000 Athens, Greece
Olympic Aquatic Centre 42500.00 11500 Athens, Greece
Markopoulo Olympic Equestrian Centre 64000.00 15000 Markopoulo, Athens, Greece
Faliro Coastal Zone Olympic Complex 34650.00 12171 Faliro, Athens, Greece
Athens Olympic Stadium 120400.00 71030 Maroussi, Athens, Greece
Ano Liossia 34000.00 12000 Ano Liosia, Athens, Greece
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-fetch" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_fetch</refname>
<refpurpose>Is used to get a single row</refpurpose>
<refpurpose>Fetches the next row from a result set</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -56,24 +56,36 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ( $con, "select * from members", CUBRID_INCLUDE_OID | CUBRID_ASYNC);
if ($req) {
while ( list ($id, $name) = cubrid_fetch ($req) ){
echo $id;
echo $name;
}
cubrid_close_request ($req);
}
$req = cubrid_execute ($con, "select * from teams");
if ($req) {
while ($row = cubrid_fetch ($req, CUBRID_OBJECT)) {
echo $row->id;
echo $row->name;
}
$conn = cubrid_connect("localhost", 33088, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM stadium WHERE nation_code='GRE' AND seats > 10000");
printf("%-40s %-10s %-6s %-20s\n", "name", "area", "seats", "address");
while ($row = cubrid_fetch($req)) {
printf("%-40s %-10s %-6s %-20s\n",
$row["name"], $row["area"], $row["seats"], $row["address"]);
}
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
name area seats address
Panathinaiko Stadium 86300.00 50000 Athens, Greece
Olympic Stadium 54700.00 13000 Athens, Greece
Olympic Indoor Hall 34100.00 18800 Athens, Greece
Olympic Hall 52400.00 21000 Athens, Greece
Olympic Aquatic Centre 42500.00 11500 Athens, Greece
Markopoulo Olympic Equestrian Centre 64000.00 15000 Markopoulo, Athens, Greece
Faliro Coastal Zone Olympic Complex 34650.00 12171 Faliro, Athens, Greece
Athens Olympic Stadium 120400.00 71030 Maroussi, Athens, Greece
Ano Liossia 34000.00 12000 Ano Liosia, Athens, Greece
]]>
</screen>
</example>
</refsect1>

View file

@ -15,7 +15,13 @@
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
This function returns a string with the flags of the given field offset separated by space. You can split the returned value using explode. The possible flags could be: <constant>not_null</constant>, <constant>primary_key</constant>, <constant>unique_key</constant>, <constant>foreign_key</constant>, <constant>auto_increment</constant>, <constant>shared</constant>, <constant>reverse_index</constant>, <constant>reverse_unique</constant> and <constant>timestamp</constant>.
This function returns a string with the flags of the given field offset
separated by space. You can split the returned value using explode. The
possible flags could be: <constant>not_null</constant>,
<constant>primary_key</constant>, <constant>unique_key</constant>,
<constant>foreign_key</constant>, <constant>auto_increment</constant>,
<constant>shared</constant>, <constant>reverse_index</constant>,
<constant>reverse_unique</constant> and <constant>timestamp</constant>.
</para>
</refsect1>
@ -23,13 +29,17 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<varlistentry>
<term><parameter>result</parameter></term>
<listitem><para><parameter>result</parameter> comes from a call to <function>cubrid_execute</function></para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>The numerical field offset. The <parameter>field_offset</parameter> starts at 0. If <parameter>field_offset</parameter> does not exist, an error of level <constant>E_WARNING</constant> is also issued.</para></listitem>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>
The numerical field offset. The <parameter>field_offset</parameter>
starts at 0. If <parameter>field_offset</parameter> does not exist, an
error of level <constant>E_WARNING</constant> is also issued.
</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -55,27 +65,31 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
$flags = cubrid_field_flags($result, 0);
print_r(explode(' ', $flags));
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM game WHERE host_year=2004 AND nation_code='AUS' AND medal='G'");
$col_num = cubrid_num_cols($result);
printf("%-30s %s\n", "Field Name", "Field Flags");
for($i = 0; $i < $col_num; $i++) {
printf("%-30s %s\n", cubrid_field_name($result, $i), cubrid_field_flags($result, $i));
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Array ( [0] => not_null [1] => unique_key [2] => auto_increment )
Field Name Field Flags
host_year not_null primary_key unique_key
event_code not_null primary_key unique_key foreign_key
athlete_code not_null primary_key unique_key foreign_key
stadium_code not_null
nation_code
medal
game_date
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-field-len" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_field_len</refname>
<refpurpose>Returns the maximum length of the specified field</refpurpose>
<refpurpose>Get the maximum length of the specified field</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -52,28 +52,33 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
$length = cubrid_field_len($result, 1);
echo "Length of NAME field is ".$length;
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM game WHERE host_year=2004 AND nation_code='AUS' AND medal='G'");
cubrid_close_request($result);
}
$column_names = cubrid_column_names($result);
$column_types = cubrid_column_types($result);
printf("%-30s %-30s %-15s\n", "Column Names", "Column Types", "Column Maxlen");
for($i = 0, $size = count($column_names); $i < $size; $i++) {
$column_len = cubrid_field_len($result, $i);
printf("%-30s %-30s %-15s\n", $column_names[$i], $column_types[$i], $column_len);
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Length of NAME field is 256
Column Names Column Types Column Maxlen
host_year integer 11
event_code integer 11
athlete_code integer 11
stadium_code integer 11
nation_code char(3) 3
medal char(1) 1
game_date date 10
]]>
</screen>
</example>

View file

@ -15,7 +15,8 @@
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the name of the specified field index on success or it returns FALSE on failure.
This function returns the name of the specified field index on success or
it returns FALSE on failure.
</para>
</refsect1>
@ -23,13 +24,17 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<varlistentry>
<term><parameter>result</parameter></term>
<listitem><para><parameter>result</parameter> comes from a call to <function>cubrid_execute</function></para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>The numerical field offset. The <parameter>field_offset</parameter> starts at 0. If <parameter>field_offset</parameter> does not exist, an error of level <constant>E_WARNING</constant> is also issued.</para></listitem>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>
The numerical field offset. The <parameter>field_offset</parameter>
starts at 0. If <parameter>field_offset</parameter> does not exist, an
error of level <constant>E_WARNING</constant> is also issued.
</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -52,29 +57,31 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
echo cubrid_field_name($result, 0)."<BR>";
echo cubrid_field_name($result, 2);
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM game WHERE host_year=2004 AND nation_code='AUS' AND medal='G'");
$col_num = cubrid_num_cols($result);
printf("%-30s %s\n", "Field Name", "Field Flags");
for($i = 0; $i < $col_num; $i++) {
printf("%-30s %s\n", cubrid_field_name($result, $i), cubrid_field_flags($result, $i));
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
id
address
Field Name Field Flags
host_year not_null primary_key unique_key
event_code not_null primary_key unique_key foreign_key
athlete_code not_null primary_key unique_key foreign_key
stadium_code not_null
nation_code
medal
game_date
]]>
</screen>
</example>

View file

@ -15,7 +15,10 @@
<methodparam choice="opt"><type>int</type><parameter>field_offset</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
This function moves the result set cursor to the specified field offset. This offset is used by <function>cubrid_fetch_field</function> if it doesn't include a field offset. It returns TRUE on success or FALSE on failure.
This function moves the result set cursor to the specified field offset.
This offset is used by <function>cubrid_fetch_field</function> if it
doesn't include a field offset. It returns TRUE on success or FALSE on
failure.
</para>
</refsect1>
@ -27,11 +30,15 @@
<term><parameter>result</parameter></term>
<listitem><para><parameter>result</parameter> comes from a call to <function>cubrid_execute</function></para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>The numerical field offset. The <parameter>field_offset</parameter> starts at 0. If <parameter>field_offset</parameter> does not exist, an error of level <constant>E_WARNING</constant> is also issued.</para></listitem>
</varlistentry>
</variablelist>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>
The numerical field offset. The <parameter>field_offset</parameter>
starts at 0. If <parameter>field_offset</parameter> does not exist, an
error of level <constant>E_WARNING</constant> is also issued.
</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
@ -52,52 +59,55 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
cubrid_field_seek($result,2);
$meta = cubrid_fetch_field($result);
if (!$meta)
{
echo "No information available<br />\n";
}
echo "<pre>
max_length: $meta->max_length
multiple_key: $meta->multiple_key
name: $meta->name
not_null: $meta->not_null
numeric: $meta->numeric
table: $meta->table
type: $meta->type
default: $meta->def
unique_key: $meta->unique_key
</pre>";
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT event_code,athlete_code,nation_code,game_date FROM game WHERE host_year=1988 and event_code=20001;");
var_dump(cubrid_fetch_row($req));
cubrid_close_request($result);
}
cubrid_field_seek($req, 1);
$field = cubrid_fetch_field($req);
printf("\n--- Field Properties ---\n");
printf("%-30s %s\n", "name:", $field->name);
printf("%-30s %s\n", "table:", $field->table);
printf("%-30s \"%s\"\n", "default value:", $field->def);
printf("%-30s %d\n", "max lenght:", $field->max_length);
printf("%-30s %d\n", "not null:", $field->not_null);
printf("%-30s %d\n", "unique key:", $field->unique_key);
printf("%-30s %d\n", "multiple key:", $field->multiple_key);
printf("%-30s %d\n", "numeric:", $field->numeric);
printf("%-30s %s\n", "type:", $field->type);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
max_length: 21
multiple_key: 1
name: address
not_null: 0
numeric: 0
table: employees
type: STRING
default:
unique_key: 0
array(4) {
[0]=>
string(5) "20001"
[1]=>
string(5) "16681"
[2]=>
string(3) "KOR"
[3]=>
string(9) "1988-9-30"
}
--- Field Properties ---
name: athlete_code
table: game
default value: ""
max lenght: 5
not null: 1
unique key: 1
multiple key: 0
numeric: 1
type: integer
]]>
</screen>
</example>

View file

@ -23,13 +23,17 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<varlistentry>
<term><parameter>result</parameter></term>
<listitem><para>Array type of the fetched result CUBRID_NUM, CUBRID_ASSOC, CUBRID_BOTH.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>The numerical field offset. The <parameter>field_offset</parameter> starts at 0. If <parameter>field_offset</parameter> does not exist, an error of level <constant>E_WARNING</constant> is also issued.</para></listitem>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>
The numerical field offset. The <parameter>field_offset</parameter>
starts at 0. If <parameter>field_offset</parameter> does not exist, an
error of level <constant>E_WARNING</constant> is also issued.
</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -55,29 +59,27 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
echo "Field 0 (<b>". cubrid_field_name($result, 0) . "</b>) is from table <i>" . cubrid_field_table($result, 0) . "</i><br>";
echo "Field 1 (<b>". cubrid_field_name($result, 1) . "</b>) is from table <i>" . cubrid_field_table($result, 1) . "</i><br>";
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM code");
$col_num = cubrid_num_cols($result);
printf("%-15s %-15s %s\n", "Field Table", "Field Name", "Field Type");
for($i = 0; $i < $col_num; $i++) {
printf("%-15s %-15s %s\n",
cubrid_field_table($result, $i), cubrid_field_name($result, $i), cubrid_field_type($result, $i));
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Field 0 (id) is from table employees
Field 1 (name) is from table employees
Field Table Field Name Field Type
code s_name char(1)
code f_name varchar(6)
]]>
</screen>
</example>

View file

@ -15,7 +15,9 @@
<methodparam><type>int</type><parameter>field_offset</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the type of the column corresponding to the given field offset. The returned field type could be one of the following: "int", "real", "string", etc.
This function returns the type of the column corresponding to the given
field offset. The returned field type could be one of the following:
"int", "real", "string", etc.
</para>
</refsect1>
@ -23,16 +25,20 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<varlistentry>
<term><parameter>result</parameter></term>
<listitem><para>Array type of the fetched result CUBRID_NUM, CUBRID_ASSOC, CUBRID_BOTH.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>The numerical field offset. The <parameter>field_offset</parameter> starts at 0. If <parameter>field_offset</parameter> does not exist, an error of level <constant>E_WARNING</constant> is also issued.</para></listitem>
<varlistentry>
<term><parameter>field_offset</parameter></term>
<listitem><para>
The numerical field offset. The <parameter>field_offset</parameter>
starts at 0. If <parameter>field_offset</parameter> does not exist, an
error of level <constant>E_WARNING</constant> is also issued.
</para></listitem>
</varlistentry>
</variablelist>
</para>
</para>
</refsect1>
<refsect1 role="returnvalues">
@ -55,29 +61,27 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
echo "Field 0 (<b>". cubrid_field_name($result, 0) . "</b>) has type <i>" . cubrid_field_type($result, 0) . "</i><br>";
echo "Field 1 (<b>". cubrid_field_name($result, 1) . "</b>) has type <i>" . cubrid_field_type($result, 1) . "</i><br>";
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM code");
$col_num = cubrid_num_cols($result);
printf("%-15s %-15s %s\n", "Field Table", "Field Name", "Field Type");
for($i = 0; $i < $col_num; $i++) {
printf("%-15s %-15s %s\n",
cubrid_field_table($result, $i), cubrid_field_name($result, $i), cubrid_field_type($result, $i));
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Field 0 (id) has type INT
Field 1 (name) has type STRING
Field Table Field Name Field Type
code s_name char(1)
code f_name varchar(6)
]]>
</screen>
</example>

View file

@ -14,7 +14,10 @@
<methodparam><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function frees the memory occupied by the result data. It returns TRUE on success or FALSE on failure.
This function frees the memory occupied by the result data. It returns
TRUE on success or FALSE on failure. Note that it can only frees the
client fetch buffer now, and if you want free all memory, use function
<function>cubrid_close_request</function>.
</para>
</refsect1>
@ -46,30 +49,34 @@
<title><function>cubrid_free_result</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
$row = cubrid_fetch_assoc($result);
/* Now we free up the result and continue on with our script */
cubrid_free_result($result);
echo $row['id']."<br>".$row['address'];
}
<?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM history WHERE host_year=2004 ORDER BY event_code");
$row = cubrid_fetch_assoc($req);
var_dump($row);
cubrid_free_result($req);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
1
1st Avenue, New York
array(5) {
["event_code"]=>
string(5) "20005"
["athlete"]=>
string(12) "Hayes Joanna"
["host_year"]=>
string(4) "2004"
["score"]=>
string(5) "12.37"
["unit"]=>
string(4) "time"
}
]]>
</screen>
</example>

View file

@ -14,7 +14,8 @@
<methodparam><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function returns This function returns the current CUBRID connection charset.
This function returns This function returns the current CUBRID connection
charset.
</para>
</refsect1>
@ -22,9 +23,9 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>The CUBRID connection.</para></listitem>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>The CUBRID connection.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -47,21 +48,55 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
printf("\n");
$conn = cubrid_connect("localhost", 33088, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
printf("CUBRID current charset: %s\n", cubrid_get_charset ($link));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
CUBRID current charset: iso8859-1
CUBRID PHP Version: 8.3.1.0005
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT -1
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.3.1.0173
Client Info: 8.3.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-get-class-name" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_get_class_name</refname>
<refpurpose>Is used to get the class name</refpurpose>
<refpurpose>Get the class name using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,8 @@
<methodparam><type>string</type><parameter>oid</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_get_class_name</function> function is used to get the class name from <parameter>oid</parameter>.
The <function>cubrid_get_class_name</function> function is used to get the
class name from <parameter>oid</parameter>.
</para>
</refsect1>
@ -23,13 +24,13 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>Connection identifier.</para></listitem>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>Connection identifier.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance that you want to check the existence.</para></listitem>
<term><parameter>oid</parameter></term>
<listitem><para>OID of the instance that you want to check the existence.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -52,16 +53,24 @@
<programlisting role="php">
<![CDATA[
<?php
$target_oid = cubrid_get ($con, $oid, "customer");
$class_name = cubrid_get_class_name ($con, $target_oid);
if ($class_name) {
echo "class name of $oid is $class_name\n";
} else {
echo "error\n";
}
$conn = cubrid_connect("localhost", 33088, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM code", CUBRID_INCLUDE_OID);
$oid = cubrid_current_oid($req);
$class_name = cubrid_get_class_name($conn, $oid);
print_r($class_name);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
code
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-get-client-info" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_get_client_info</refname>
<refpurpose>Returns a string that represents the client library version</refpurpose>
<refpurpose>Returns the client library version</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -42,15 +42,55 @@
<programlisting role="php">
<![CDATA[
<?php
printf("CUBRID client info: %s\n", cubrid_get_client_info());
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
printf("\n");
$conn = cubrid_connect("localhost", 33088, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
CUBRID client info: 8.2.1
CUBRID PHP Version: 8.3.1.0005
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT -1
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.3.1.0173
Client Info: 8.3.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>

View file

@ -14,25 +14,127 @@
<methodparam><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the CUBRID database parameters or it returns FALSE on failure. It returns an associative array with the values for the following parameters:
This function returns the CUBRID database parameters or it returns FALSE on
failure. It returns an associative array with the values for the following
parameters:
</para>
<para>
<simplelist>
<member><constant>CCI_PARAM_ISOLATION_LEVEL</constant></member>
<member><constant>CCI_PARAM_LOCK_TIMEOUT</constant></member>
<member><constant>CCI_PARAM_MAX_STRING_LENGTH</constant></member>
<member><constant>CCI_PARAM_AUTO_COMMIT</constant></member>
<member><constant>PARAM_ISOLATION_LEVEL</constant></member>
<member><constant>LOCK_TIMEOUT</constant></member>
<member><constant>MAX_STRING_LENGTH</constant></member>
<member><constant>PARAM_AUTO_COMMIT</constant></member>
</simplelist>
</para>
<para>
<table>
<title>Database parameters</title>
<tgroup cols="2">
<thead>
<row>
<entry>Parameter</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>PARAM_ISOLATION_LEVEL</entry>
<entry>In current version CUBRID PHP, you can set the level of
transaction isolation by using isolation_level in the
$CUBRID/conf/cubrid.conf or the SET TRANSACTION statement. In next
version, isolation level can be set using new CUBRID PHP API.
</entry>
</row>
<row>
<entry>LOCK_TIMEOUT</entry>
<entry>CUBRID provides the lock timeout feature, which sets the waiting
time for the lock until the transaction lock setting is allowed. The
system parameter lock_timeout_in_secs in the $CUBRID/conf/cubrid.conf
file or the SET TRANSACTION statement sets the timeout (in seconds).
In next version, lock timeout can be set using new CUBRID PHP API.
The default value of the lock_timeout_in_secs parameter is -1, which
means the application client will wait indefinitely until the
transaction lock is allowed.</entry>
</row>
<row>
<entry>PARAM_AUTO_COMMIT</entry>
<entry>In CUBRID PHP, an auto-commit mode is disabled by default for
transaction management, and it can't be enabled in current version
CUBRID PHP. It can be set in next version. And auto commit modes can
be applied only for SELECT statements by setting broker
parameters.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
The following table shows the isolation levels from 1 to 6. It consists of
table schema (row) and isolation level:
<table>
<title>Levels of Isolation Supported by CUBRID</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>SERIALIZABLE (6)</entry>
<entry>In this isolation level, problems concerning concurrency (e.g.
dirty read, non-repeatable read, phantom read, etc.) do not
occur.</entry>
</row>
<row>
<entry>REPEATABLE READ CLASS with REPEATABLE READ INSTANCES (5)</entry>
<entry>Another transaction T2 cannot update the schema of table A while
transaction T1 is viewing table A.
Transaction T1 may experience phantom read for the record R that was
inserted by another transaction T2 when it is repeatedly retrieving a
specific record.</entry>
</row>
<row>
<entry>REPEATABLE READ CLASS with READ UNCOMMITTED INSTANCES (3)</entry>
<entry>Default isolation level. Another transaction T2 cannot update
the schema of table A while transaction T1 is viewing table A.
Transaction T1 may experience R' read (dirty read) for the record that
was updated but not committed by another transaction T2.</entry>
</row>
<row>
<entry>READ COMMITTED CLASS with READ COMMITTED INSTANCES (2)</entry>
<entry>Transaction T1 may experience A' read (non-repeatable read) for
the table that was updated and committed by another transaction T2
while it is viewing table A repeatedly. Transaction T1 may experience
R' read (non-repeatable read) for the record that was updated and
committed by another transaction T2 while it is retrieving the record
R repeatedly.</entry>
</row>
<row>
<entry>READ COMMITTED CLASS with READ UNCOMMITTED INSTANCES (1)</entry>
<entry>Transaction T1 may experience A' read (non-repeatable read) for
the table that was updated and committed by another transaction T2
while it is repeatedly viewing table A. Transaction T1 may experience
R' read (dirty read) for the record that was updated but not committed
by another transaction T2.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>The CUBRID connection. If the connection identifier is not specified, the last link opened by <function>cubrid_connect</function> is assumed. </para></listitem>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>
The CUBRID connection. If the connection identifier is not specified,
the last link opened by <function>cubrid_connect</function> is assumed.
</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -55,27 +157,59 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
echo "CUBRID parameters:<br>";
print_r(cubrid_get_db_parameter($link));
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
printf("\n");
$conn = cubrid_connect("localhost", 33088, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
CUBRID parameters:
Array ( [PARAM_ISOLATION_LEVEL] => 3 [LOCK_TIMEOUT] => -1 [MAX_STRING_LENGTH] => 1073741823 )
CUBRID PHP Version: 8.3.1.0005
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT -1
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.3.1.0173
Client Info: 8.3.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-get-server-info" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_get_server_info</refname>
<refpurpose>Returns a string that represents the CUBRID server version</refpurpose>
<refpurpose>Returns the CUBRID server version</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -47,21 +47,55 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
printf("\n");
$conn = cubrid_connect("localhost", 33088, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
printf("CUBRID server info: %s\n", cubrid_get_server_info($link));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
CUBRID server info: 8.2.1.0209
CUBRID PHP Version: 8.3.1.0005
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT -1
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.3.1.0173
Client Info: 8.3.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-get" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_get</refname>
<refpurpose>Is used to get the attribute</refpurpose>
<refpurpose>Get a column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -16,7 +16,11 @@
<methodparam choice="opt"><type>mixed</type><parameter>attr</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_get</function> function is used to get the attribute of the instance of the given <parameter>oid</parameter>. You can get single attribute by using string data type for the <parameter>attr</parameter> argument, or many attributes by using array data type for the <parameter>attr</parameter> argument.
The <function>cubrid_get</function> function is used to get the attribute
of the instance of the given <parameter>oid</parameter>. You can get
single attribute by using string data type for the
<parameter>attr</parameter> argument, or many attributes by using array
data type for the <parameter>attr</parameter> argument.
</para>
</refsect1>
@ -30,7 +34,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance that you want to read.</para></listitem>
<listitem><para>OID of the instance that you want to read.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr</parameter></term>
@ -44,10 +48,17 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Content of the requested attribute, when process is successful; When <parameter>attr</parameter> is set with string data type, the result is returned as a string; when <parameter>attr</parameter> is set with array data type (0-based numerical array), then the result is returned in associative array. When <parameter>attr</parameter> is omitted, then all attributes are received in array form.
Content of the requested attribute, when process is successful; When
<parameter>attr</parameter> is set with string data type, the result is
returned as a string; when <parameter>attr</parameter> is set with array
data type (0-based numerical array), then the result is returned in
associative array. When <parameter>attr</parameter> is omitted, then all
attributes are received in array form.
</para>
<para>
&false; when process is unsuccessful or result is NULL (If error occurs to distinguish empty string from NULL, then it prints the warning message. You can check the error by using <function>cubrid_error_code</function>)
&false; when process is unsuccessful or result is NULL (If error occurs to
distinguish empty string from NULL, then it prints the warning message.
You can check the error by using <function>cubrid_error_code</function>)
</para>
</refsect1>
@ -58,12 +69,61 @@
<programlisting role="php">
<![CDATA[
<?php
$attrarray = cubrid_get ($con, $oid);
echo $attrarray["id"];
echo $attrarray["name"];
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(2, {4,5,7}, {44,55,66,666}, 'b')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_get($conn, $oid, "b");
var_dump($attr);
$attr = cubrid_get($conn, $oid);
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(9) "{1, 2, 3}"
array(4) {
["a"]=>
string(1) "1"
["b"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
["c"]=>
array(4) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
}
["d"]=>
string(10) "a "
}
]]>
</screen>
</example>
</refsect1>

View file

@ -15,7 +15,12 @@
<methodparam choice="opt"><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function returns an array with the IDs generated for the <constant>AUTO_INCREMENT</constant> columns that were updated by the previous INSERT query. It returns an array with all the <constant>AUTO_INCREMENT</constant> columns and their values. It returns 0 if the previous query does not generate new rows, or it returns FALSE on failure.
This function returns an array with the IDs generated for the
<constant>AUTO_INCREMENT</constant> columns that were updated by the
previous INSERT query. It returns an array with all the
<constant>AUTO_INCREMENT</constant> columns and their values. It returns 0
if the previous query does not generate new rows, or it returns FALSE on
failure.
</para>
</refsect1>
@ -23,13 +28,19 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>class_name</parameter></term>
<listitem><para>The name of the class (table) that was used in the last INSERT statement for which the auto increment values are retrieved.</para></listitem>
<varlistentry>
<term><parameter>class_name</parameter></term>
<listitem><para>
The name of the class (table) that was used in the last INSERT statement
for which the auto increment values are retrieved.
</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>The connection identifier previously obtained by a call to <function>cubrid_connect</function>.</para></listitem>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>
The connection identifier previously obtained by a call to
<function>cubrid_connect</function>.
</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -55,28 +66,29 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = "insert into employees (name, address, salary) values ('Michael', 'Boston, MA', 3750)";
$result = cubrid_execute($link, $query);
if ($result)
{
$array_id = cubrid_insert_id("employees");
echo "Last insert id was ".$array_id["id"];
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE cubrid_test");
cubrid_execute($conn, "CREATE TABLE cubrid_test (d int AUTO_INCREMENT(1, 2), t varchar)");
for ($i = 0; $i < 10; $i++) {
cubrid_execute($conn, "INSERT INTO cubrid_test(t) VALUES('cubrid_test')");
}
$id_list = cubrid_insert_id("cubrid_test");
var_dump($id_list);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
Last insert id was 10
array(1) {
["d"]=>
int(19)
}
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-is-instance" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_is_instance</refname>
<refpurpose>Is used to check whether the instance</refpurpose>
<refpurpose>Check whether the instance pointed by OID exists</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,9 @@
<methodparam><type>string</type><parameter>oid</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_is_instance</function> function is used to check whether the instance pointed by the given <parameter>oid</parameter> exists or not.
The <function>cubrid_is_instance</function> function is used to check
whether the instance pointed by the given <parameter>oid</parameter>
exists or not.
</para>
</refsect1>
@ -29,7 +31,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance that you want to check the existence.</para></listitem>
<listitem><para>OID of the instance that you want to check the existence.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -55,18 +57,37 @@
<programlisting role="php">
<![CDATA[
<?php
$target_oid = cubrid_get ($con, $oid, "customer");
$res = cubrid_is_instance ($con, $target_oid);
$conn = cubrid_connect("localhost", 33000, "demodb");
$sql = <<<EOD
SELECT host_year, medal, game_date
FROM game
WHERE athlete_code IN
(SELECT code FROM athlete WHERE name='Thorpe Ian');
EOD;
$req = cubrid_execute($conn, $sql, CUBRID_INCLUDE_OID);
$oid = cubrid_current_oid($req);
$res = cubrid_is_instance ($conn, $oid);
if ($res == 1) {
echo "$oid is presents.\n";
echo "Instance pointed by $oid exists.\n";
} else if ($res == 0){
echo "$oid is not presents.\n";
echo "Instance pointed by $oid doesn't exist.\n";
} else {
echo "error\n";
echo "error\n";
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Instance pointed by @0|0|0 doesn't exist.
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-list-dbs" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_list_dbs</refname>
<refpurpose>Returns an array with the list of all existing Cubrid databases</refpurpose>
<refpurpose>Returns an array with the list of all existing CUBRID databases</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,8 @@
<methodparam><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function returns an array with the list of all existing Cubrid databases.
This function returns an array with the list of all existing Cubrid
databases.
</para>
</refsect1>
@ -47,22 +48,22 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
echo "CUBRID databases:<br>";
print_r(cubrid_list_dbs($link));
$conn = cubrid_connect("localhost", 33088, "demodb");
$db_list = cubrid_list_dbs($conn);
var_dump($db_list);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
CUBRID databases:
Array ( [0] => demodb2 [1] => cubrid3 )
array(1) {
[0]=>
string(6) "demodb"
}
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-lock-read" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_lock_read</refname>
<refpurpose>Is used to put read lock</refpurpose>
<refpurpose>Sets a read lock on the given OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,8 @@
<methodparam><type>string</type><parameter>oid</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_lock_read</function> function is used to put read lock on the instance pointed by given <parameter>oid</parameter>.
The <function>cubrid_lock_read</function> function is used to put read
lock on the instance pointed by given <parameter>oid</parameter>.
</para>
</refsect1>
@ -23,13 +24,13 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>Connection identifier.</para></listitem>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>Connection identifier.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance that you want to put read lock on.</para></listitem>
<listitem><para>OID of the instance that you want to put read lock on.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -52,11 +53,63 @@
<programlisting role="php">
<![CDATA[
<?php
$lock_oid = cubrid_get ($con, $oid, "next_id");
$res = cubrid_lock_read ($con, $lock_oid);
$conn = cubrid_connect("localhost", 33088, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(2, {4,5,7}, {44,55,66,666}, 'b')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
cubrid_lock_read($conn, $oid);
$attr = cubrid_get($conn, $oid, "b");
var_dump($attr);
$attr = cubrid_get($conn, $oid);
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(9) "{1, 2, 3}"
array(4) {
["a"]=>
string(1) "1"
["b"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
["c"]=>
array(4) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
}
["d"]=>
string(10) "a "
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-lock-write" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_lock_write</refname>
<refpurpose>Is used to put write lock</refpurpose>
<refpurpose>Sets a write lock on the given OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,8 @@
<methodparam><type>string</type><parameter>oid</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_lock_write</function> function is used to put write lock on the instance pointed by the given <parameter>oid</parameter>.
The <function>cubrid_lock_write</function> function is used to put write
lock on the instance pointed by the given <parameter>oid</parameter>.
</para>
</refsect1>
@ -29,7 +30,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance that you want to put write lock on.</para></listitem>
<listitem><para>OID of the instance that you want to put write lock on.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -52,11 +53,54 @@
<programlisting role="php">
<![CDATA[
<?php
$lock_oid = cubrid_get ($con, $oid, "next_id");
$res = cubrid_lock_write ($con, $lock_oid);
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(2, {4,5,7}, {44,55,66,666}, 'b')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
cubrid_lock_write($conn, $oid);
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_put($conn, $oid, "b", array(2, 4, 8));
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
array(3) {
[0]=>
string(1) "2"
[1]=>
string(1) "4"
[2]=>
string(1) "8"
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-move-cursor" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_move_cursor</refname>
<refpurpose>Is used to move the current cursor location</refpurpose>
<refpurpose>Move the cursor in the result</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -16,10 +16,22 @@
<methodparam choice="opt"><type>int</type><parameter>origin</parameter><initializer>CUBRID_CURSOR_CURRENT</initializer></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_move_cursor</function> function is used to move the current cursor location of <parameter>req_identifier</parameter> by the value set in the <parameter>offset</parameter> argument, to the direction set in the <parameter>origin</parameter> argument. To set the <parameter>origin</parameter> argument, you can use CUBRID_CURSOR_FIRST for the first part of the result, CUBRID_CURSOR_CURRENT for the current location of the result, or CUBRID_CURSOR_LAST for the last part of the result. If <parameter>origin</parameter> argument is not explicitly designated, then the function uses CUBRID_CURSOR_CURRENT as its default value.
The <function>cubrid_move_cursor</function> function is used to move the
current cursor location of <parameter>req_identifier</parameter> by the
value set in the <parameter>offset</parameter> argument, to the direction
set in the <parameter>origin</parameter> argument. To set the
<parameter>origin</parameter> argument, you can use CUBRID_CURSOR_FIRST
for the first part of the result, CUBRID_CURSOR_CURRENT for the current
location of the result, or CUBRID_CURSOR_LAST for the last part of the
result. If <parameter>origin</parameter> argument is not explicitly
designated, then the function uses CUBRID_CURSOR_CURRENT as its default
value.
</para>
<para>
If the value of cursor movement range goes over the valid limit, then the cursor moves to the next location after the valid range for the cursor. For example, if you move 20 units in the result with the size of 10, then the cursor will move to 11th place and return CUBRID_NO_MORE_DATA.
If the value of cursor movement range goes over the valid limit, then the
cursor moves to the next location after the valid range for the cursor.
For example, if you move 20 units in the result with the size of 10, then
the cursor will move to 11th place and return CUBRID_NO_MORE_DATA.
</para>
</refsect1>
@ -63,18 +75,50 @@
<programlisting role="php">
<![CDATA[
<?php
cubrid_move_cursor ($req_handle, 1, CUBRID_CURSOR_FIRST);
// move to the first possible cursor location
$row = cubrid_fetch ($req_handle);
echo $row["id"], $row["name"];
$conn = cubrid_connect("127.0.0.1", 33000, "demodb");
cubrid_move_cursor ($req_handle, 1, CUBRID_CURSOR_LAST);
// move to the last possible cursor location
$row = cubrid_fetch ($req_handle);
echo $row["id"], $row["name"];
$req = cubrid_execute($conn, "SELECT * FROM code");
cubrid_move_cursor($req, 1, CUBRID_CURSOR_LAST);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_CURRENT);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(2) {
[0]=>
string(1) "G"
[1]=>
string(4) "Gold"
}
array(2) {
[0]=>
string(1) "X"
[1]=>
string(5) "Mixed"
}
array(2) {
[0]=>
string(1) "M"
[1]=>
string(3) "Man"
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-num-cols" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_num_cols</refname>
<refpurpose>Is used to get the number of columns</refpurpose>
<refpurpose>Returns the number of columns in the result set</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,9 @@
<methodparam><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_num_cols</function> function is used to get the number of columns from the query result. It can only be used when the query executed is a select sentence.
The <function>cubrid_num_cols</function> function is used to get the
number of columns from the query result. It can only be used when the
query executed is a select sentence.
</para>
</refsect1>
@ -47,21 +49,30 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "select * from member");
if ($req) {
$rows_count = cubrid_num_rows ($req);
$cols_count = cubrid_num_cols ($req);
echo "result set rows count : $rows\n";
echo "result set columns count : $cols\n";
cubrid_close_request ($req);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM code");
$row_num = cubrid_num_rows($req);
$col_num = cubrid_num_cols($req);
printf("Row Num: %d\nColumn Num: %d\n", $row_num, $col_num);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Row Num: 6
Column Num: 2
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>

View file

@ -14,7 +14,8 @@
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the number of columns in the result set, on success, or it returns FALSE on failure.
This function returns the number of columns in the result set, on success,
or it returns FALSE on failure.
</para>
</refsect1>
@ -47,30 +48,24 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
$n = cubrid_num_fields($result);
echo "The resultset contains ".$n. " fields: ";
for ($i = 0; $i < $n; $i++)
echo cubrid_field_name($result, $i)." ";
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM code");
$row_num = cubrid_num_rows($req);
$col_num = cubrid_num_fields($req);
printf("Row Num: %d\nColumn Num: %d\n", $row_num, $col_num);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
The resultset contains 4 fields: id name address salary
Row Num: 6
Column Num: 2
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-num-rows" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_num_rows</refname>
<refpurpose>Is used to get the number of rows</refpurpose>
<refpurpose>Get the number of rows in the result set</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,10 +14,15 @@
<methodparam><type>resource</type><parameter>req_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_num_rows</function> function is used to get the number of rows from the query result. You can use it only when the query executed is a select sentence. When you want to know such value for INSERT, UPDATE, or DELETE query, you have to use the <function>cubrid_affected_rows</function> function.
The <function>cubrid_num_rows</function> function is used to get the
number of rows from the query result. You can use it only when the query
executed is a select sentence. When you want to know such value for
INSERT, UPDATE, or DELETE query, you have to use the
<function>cubrid_affected_rows</function> function.
</para>
<para>
Note: The <function>cubrid_num_rows</function> function can only be used for synchronous query; it returns 0 when it is used for asynchronous query.
Note: The <function>cubrid_num_rows</function> function can only be used
for synchronous query; it returns 0 when it is used for asynchronous query.
</para>
</refsect1>
@ -53,17 +58,26 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($con, "select * from member");
if ($req) {
$rows_count = cubrid_num_rows ($req);
$cols_count = cubrid_num_cols ($req);
echo "result set rows count : $rows\n";
echo "result set columns count : $cols\n";
cubrid_close_request ($req);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM code");
$row_num = cubrid_num_rows($req);
$col_num = cubrid_num_cols($req);
printf("Row Num: %d\nColumn Num: %d\n", $row_num, $col_num);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Row Num: 6
Column Num: 2
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-prepare" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_prepare</refname>
<refpurpose>Is a sort of API which represents SQL statements</refpurpose>
<refpurpose>Prepare an SQL statement for execution</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -60,20 +60,47 @@
<programlisting role="php">
<![CDATA[
<?php
if ($con) {
$sql = "insert into tbl values ( ?,?,?)";
$req = cubrid_prepare( $con, $sql, CUBRID_INCLUDE_OID );
$i = 0;
while ( $i < 2 ) {
$res = cubrid_bind( $req, 1, "1", "NUMBER");
$res = cubrid_bind( $req, 2, "2");
$res = cubrid_bind( $req, 3, "04:22:34 PM 08/07/2007");
$res = cubrid_execute( $req );
$i = $i + 1;
}}
$conn = cubrid_connect("localhost", 33000, "demodb");
$sql = <<<EOD
SELECT g.event_code, e.name
FROM game g
JOIN event e ON g.event_code=e.code
WHERE host_year = ? AND event_code NOT IN (SELECT event_code FROM game WHERE host_year=?) GROUP BY event_code;
EOD;
$req = cubrid_prepare($conn, $sql);
cubrid_bind($req, 1, 2004);
cubrid_bind($req, 2, 2000);
cubrid_execute($req);
$row_num = cubrid_num_rows($req);
printf("There are %d event that exits in 2004 olympic but not in 2000. For example:\n\n", $row_num);
printf("%-15s %s\n", "Event_code", "Event_name");
printf("----------------------------\n");
$row = cubrid_fetch_assoc($req);
printf("%-15d %s\n", $row["event_code"], $row["name"]);
$row = cubrid_fetch_assoc($req);
printf("%-15d %s\n", $row["event_code"], $row["name"]);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
There are 27 event that exits in 2004 olympic but not in 2000. For example:
Event_code Event_name
----------------------------
20063 +91kg
20070 64kg
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-put" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_put</refname>
<refpurpose>Is used to update an attribute</refpurpose>
<refpurpose>Update a column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -17,10 +17,16 @@
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_put</function> function is used to update an attribute of the instance of the given <parameter>oid</parameter>.
The <function>cubrid_put</function> function is used to update an
attribute of the instance of the given <parameter>oid</parameter>.
</para>
<para>
You can update single attribute by using string data type to set <parameter>attr</parameter>. In such case, you can use integer, float-point, or string type data for the <parameter>value</parameter> argument. To update multiple number of attributes, you can disregard the <parameter>attr</parameter> argument, and set <parameter>value</parameter> argument with associative array data type. However, you cannot use the method for attribute of collection type. You have to use APIs related to collection type (<function>cubrid_set_add</function>, <function>cubrid_set_drop</function>, etc) when you want to use <function>cubrid_put</function> on collection typed attribute.
You can update single attribute by using string data type to set
<parameter>attr</parameter>. In such case, you can use integer,
float-point, or string type data for the <parameter>value</parameter>
argument. To update multiple number of attributes, you can disregard the
<parameter>attr</parameter> argument, and set
<parameter>value</parameter> argument with associative array data type.
</para>
</refsect1>
@ -28,21 +34,21 @@
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>Connection identifier.</para></listitem>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>Connection identifier.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance that you want to update.</para></listitem>
<term><parameter>oid</parameter></term>
<listitem><para>OID of the instance that you want to update.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr</parameter></term>
<listitem><para>Name of the attribute that you want to update.</para></listitem>
<term><parameter>attr</parameter></term>
<listitem><para>Name of the attribute that you want to update.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem><para>New value that you want to assign to the attribute.</para></listitem>
<term><parameter>value</parameter></term>
<listitem><para>New value that you want to assign to the attribute.</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -65,14 +71,52 @@
<programlisting role="php">
<![CDATA[
<?php
$attrarray = cubrid_get ($con, $oid);
$attrarray["name"] = "New Name";
cubrid_put ($con, $oid, $attrarray);
cubrid_put ($con, $oid, "name", "New Name2");
cubrid_put ($con, $oid, "hobbies", array("aa", "bb"));
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(2, {4,5,7}, {44,55,66,666}, 'b')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_put($conn, $oid, "b", array(2, 4, 8));
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
array(3) {
[0]=>
string(1) "2"
[1]=>
string(1) "4"
[2]=>
string(1) "8"
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-real-escape-string" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_real_escape_string</refname>
<refpurpose>Returns the escaped string version of the given string</refpurpose>
<refpurpose>Escapes special characters in a string for use in an SQL statement</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,17 @@
<methodparam choice="opt"><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the escaped string version of the given string. It pre-appends backslashes to the following characters: <constant>'</constant>. This function must always (with few exceptions) be used to make data safe before sending a query to CUBRID.
This function returns the escaped string version of the given string. It
will escape the following characters: <constant>'</constant>.
In general, single quotations are used to enclose character string. Double
quotations may be used as well depending on the value of ansi_quotes,
which is a parameter related to SQL statement. If the ansi_quotes value is
set to no, character string enclosed by double quotations is handled as
character string, not as an identifier. The default value is yes.
If you want to include a single quote as part of a character string, enter
two single quotes in a row.
</para>
</refsect1>
@ -24,13 +34,16 @@
<para>
<variablelist>
<varlistentry>
<term><parameter>unescaped_string</parameter></term>
<listitem><para>The string that is to be escaped.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>The CUBRID connection. If the connection identifier is not specified, the last link opened by <function>cubrid_connect</function> is assumed.</para></listitem>
</varlistentry>
<term><parameter>unescaped_string</parameter></term>
<listitem><para>The string that is to be escaped.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>
The CUBRID connection. If the connection identifier is not specified, the
last connection opened by <function>cubrid_connect</function> is assumed.
</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
@ -52,21 +65,34 @@
<programlisting role="php">
<![CDATA[
<?php
$user = "'username'";
$password = "\"pass\"";
$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
cubrid_real_escape_string($user),
cubrid_real_escape_string($password));
echo $query;
$conn = cubrid_connect("localhost", 33000, "demodb");
$unescaped_str = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$escaped_str = cubrid_real_escape_string($unescaped_str);
$len = strlen($unescaped_str);
@cubrid_execute($conn, "DROP TABLE cubrid_test");
cubrid_execute($conn, "CREATE TABLE cubrid_test (t char($len))");
cubrid_execute($conn, "INSERT INTO cubrid_test (t) VALUES('$escaped_str')");
$req = cubrid_execute($conn, "SELECT * FROM cubrid_test");
$row = cubrid_fetch_assoc($req);
var_dump($row);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
SELECT * FROM users WHERE user='\'username\'' AND password='"pass"'
array(1) {
["t"]=>
string(95) " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
}
]]>
</screen>
</example>

View file

@ -16,7 +16,8 @@
<methodparam choice="opt"><type>mixed</type><parameter>field</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
This function returns the value of a specific field in a specific row from a result set.
This function returns the value of a specific field in a specific row from
a result set.
</para>
</refsect1>
@ -34,7 +35,13 @@
</varlistentry>
<varlistentry>
<term><parameter>field</parameter></term>
<listitem><para>The name or offset of the <parameter>field</parameter> being retrieved. It can be the field's offset, the field's name, or the field's table dot field name (tablename.fieldname). If the column name has been aliased ('select foo as bar from...'), use the alias instead of the column name. If undefined, the first field is retrieved.</para></listitem>
<listitem><para>
The name or offset of the <parameter>field</parameter> being retrieved. It
can be the field's offset, the field's name, or the field's table dot
field name (tablename.fieldname). If the column name has been aliased
('select foo as bar from...'), use the alias instead of the column name.
If undefined, the first field is retrieved.
</para></listitem>
</varlistentry>
</variablelist>
</para>
@ -57,27 +64,30 @@
<programlisting role="php">
<![CDATA[
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = 'SELECT id, name, address, salary FROM employees';
$result = cubrid_execute($link, $query);
if ($result)
{
echo "The address value of third record is ".cubrid_result($result, 2, 2);
cubrid_close_request($result);
}
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM code");
$result = cubrid_result($req, 0);
var_dump($result);
$result = cubrid_result($req, 0, 1);
var_dump($result);
$result = cubrid_result($req, 5, "f_name");
var_dump($result);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
The address value of third record is 81254, CA
string(1) "X"
string(5) "Mixed"
string(4) "Gold"
]]>
</screen>
</example>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-rollback" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_rollback</refname>
<refpurpose>Executes rollback on the transaction</refpurpose>
<refpurpose>Rolls back a transaction</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,10 +14,14 @@
<methodparam><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_rollback</function> function executes rollback on the transaction pointed by <parameter>conn_handle</parameter>, currently in progress.
The <function>cubrid_rollback</function> function executes rollback on the
transaction pointed by <parameter>conn_identifier</parameter>, currently in
progress.
</para>
<para>
Connection to server is closed after calling <function>cubrid_rollback</function>. Connection handle, however, is still valid.
Connection to server is closed after calling
<function>cubrid_rollback</function>. Connection handle, however, is
still valid.
</para>
</refsect1>
@ -50,18 +54,72 @@
<programlisting role="php">
<![CDATA[
<?php
$req = cubrid_execute ($oid, "insert into person values (2,John)");
if ($req) {
cubrid_close_request ($req);
if ($failed) {
cubrid_rollback ($con);
} else {
cubrid_commit ($con);
}
$conn = cubrid_connect("127.0.0.1", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE publishers");
$sql = <<<EOD
CREATE TABLE publishers(
pub_id CHAR(3),
pub_name VARCHAR(20),
city VARCHAR(15),
state CHAR(2),
country VARCHAR(15)
)
EOD;
if (!cubrid_execute($conn, $sql)) {
printf("Error facility: %d\nError code: %d\nError msg: %s\n", cubrid_error_code_facility(), cubrid_error_code(), cubrid_error_msg());
cubrid_disconnect($conn);
exit;
}
$req = cubrid_prepare($conn, "INSERT INTO publishers VALUES(?, ?, ?, ?, ?)");
$id_list = array("P01", "P02", "P03", "P04");
$name_list = array("Abatis Publishers", "Core Dump Books", "Schadenfreude Press", "Tenterhooks Press");
$city_list = array("New York", "San Francisco", "Hamburg", "Berkeley");
$state_list = array("NY", "CA", NULL, "CA");
$country_list = array("USA", "USA", "Germany", "USA");
for ($i = 0, $size = count($id_list); $i < $size; $i++) {
cubrid_bind($req, 1, $id_list[$i]);
cubrid_bind($req, 2, $name_list[$i]);
cubrid_bind($req, 3, $city_list[$i]);
cubrid_bind($req, 4, $state_list[$i]);
cubrid_bind($req, 5, $country_list[$i]);
if (!($ret = cubrid_execute($req))) {
break;
}
}
if (!$ret) {
cubrid_rollback($conn);
} else {
cubrid_commit($conn);
$req = cubrid_execute($conn, "SELECT * FROM publishers");
while ($result = cubrid_fetch_assoc($req)) {
printf("%-3s %-20s %-15s %-3s %-15s\n",
$result["pub_id"], $result["pub_name"], $result["city"], $result["state"], $result["country"]);
}
}
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
P01 Abatis Publishers New York NY USA
P02 Core Dump Books San Francisco CA USA
P03 Schadenfreude Press Hamburg Germany
P04 Tenterhooks Press Berkeley CA USA
]]>
</screen>
</example>
</refsect1>

View file

@ -153,7 +153,7 @@
</row>
<row>
<entry>CUBRID_SCH_METHOD</entry>
<entry>CUBRID_SCH_METHOD / CUBRID_SCH_CLASS_METHOD</entry>
<entry>1</entry>
<entry>NAME</entry>
<entry></entry>
@ -179,7 +179,7 @@
</row>
<row>
<entry>CUBRID_SCH_SUPERCLASS / CUBRID_SCH_SUBCLASS</entry>
<entry>CUBRID_SCH_SUPERCLASS / CUBRID_SCH_DIRECT_SUPER_CLASS / CUBRID_SCH_SUBCLASS</entry>
<entry>1</entry>
<entry>CLASS_NAME</entry>
<entry></entry>
@ -465,14 +465,145 @@
<programlisting role="php">
<![CDATA[
<?php
$attrs = cubrid_schema ($con, CUBRID_SCH_ATTRIBUTE, "person");
while (list($key, $value) = each($attrs)) {
echo $value["NAME"];
echo $value["DOMAIN"];
}
$conn = cubrid_connect("localhost", 33000, "demodb");
printf("\n--- Primary Key ---\n");
$pk = cubrid_schema($conn, CUBRID_SCH_PRIMARY_KEY, "game");
var_dump($pk);
printf("\n--- Foreign Keys ---\n");
$fk = cubrid_schema($conn, CUBRID_SCH_IMPORTED_KEYS, "game");
var_dump($fk);
printf("\n--- Column Attribute ---\n");
$attr = cubrid_schema($conn, CUBRID_SCH_ATTRIBUTE, "stadium", "area");
var_dump($attr);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
--- Primary Key ---
array(3) {
[0]=>
array(4) {
["CLASS_NAME"]=>
string(4) "game"
["ATTR_NAME"]=>
string(12) "athlete_code"
["KEY_SEQ"]=>
string(1) "3"
["KEY_NAME"]=>
string(41) "pk_game_host_year_event_code_athlete_code"
}
[1]=>
array(4) {
["CLASS_NAME"]=>
string(4) "game"
["ATTR_NAME"]=>
string(10) "event_code"
["KEY_SEQ"]=>
string(1) "2"
["KEY_NAME"]=>
string(41) "pk_game_host_year_event_code_athlete_code"
}
[2]=>
array(4) {
["CLASS_NAME"]=>
string(4) "game"
["ATTR_NAME"]=>
string(9) "host_year"
["KEY_SEQ"]=>
string(1) "1"
["KEY_NAME"]=>
string(41) "pk_game_host_year_event_code_athlete_code"
}
}
--- Foreign Keys ---
array(2) {
[0]=>
array(9) {
["PKTABLE_NAME"]=>
string(7) "athlete"
["PKCOLUMN_NAME"]=>
string(4) "code"
["FKTABLE_NAME"]=>
string(4) "game"
["FKCOLUMN_NAME"]=>
string(12) "athlete_code"
["KEY_SEQ"]=>
string(1) "1"
["UPDATE_RULE"]=>
string(1) "1"
["DELETE_RULE"]=>
string(1) "1"
["FK_NAME"]=>
string(20) "fk_game_athlete_code"
["PK_NAME"]=>
string(15) "pk_athlete_code"
}
[1]=>
array(9) {
["PKTABLE_NAME"]=>
string(5) "event"
["PKCOLUMN_NAME"]=>
string(4) "code"
["FKTABLE_NAME"]=>
string(4) "game"
["FKCOLUMN_NAME"]=>
string(10) "event_code"
["KEY_SEQ"]=>
string(1) "1"
["UPDATE_RULE"]=>
string(1) "1"
["DELETE_RULE"]=>
string(1) "1"
["FK_NAME"]=>
string(18) "fk_game_event_code"
["PK_NAME"]=>
string(13) "pk_event_code"
}
}
--- Column Attribute ---
array(1) {
[0]=>
array(13) {
["ATTR_NAME"]=>
string(4) "area"
["DOMAIN"]=>
string(1) "7"
["SCALE"]=>
string(1) "2"
["PRECISION"]=>
string(2) "10"
["INDEXED"]=>
string(1) "0"
["NON_NULL"]=>
string(1) "0"
["SHARED"]=>
string(1) "0"
["UNIQUE"]=>
string(1) "0"
["DEFAULT"]=>
NULL
["ATTR_ORDER"]=>
string(1) "4"
["CLASS_NAME"]=>
string(7) "stadium"
["SOURCE_CLASS"]=>
string(7) "stadium"
["IS_KEY"]=>
string(1) "0"
}
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-seq-drop" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_seq_drop</refname>
<refpurpose>Is used to delete an element</refpurpose>
<refpurpose>Delete an element from sequence type column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -17,7 +17,9 @@
<methodparam><type>int</type><parameter>index</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_seq_drop</function> function is used to delete an element you request from the given sequence type attribute in the database.
The <function>cubrid_seq_drop</function> function is used to delete an
element you request from the given sequence type attribute in the
database.
</para>
</refsect1>
@ -31,7 +33,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance you want to work with.</para></listitem>
<listitem><para>OID of the instance you want to work with.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr_name</parameter></term>
@ -62,18 +64,53 @@
<programlisting role="php">
<![CDATA[
<?php
$elems = cubrid_col_get ($con, $oid, "style");
$i = 1;
while (list ($key, $val) = each($elems)) {
if ($val == "1") {
echo $val;
cubrid_seq_drop ($con, $oid, "style", $i);
}
$i++;
}
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c sequence(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "c");
var_dump($attr);
cubrid_seq_drop($conn, $oid, "c", 4);
$attr = cubrid_col_get($conn, $oid, "c");
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(4) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
}
array(3) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-seq-insert" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_seq_insert</refname>
<refpurpose>Is used to insert an element to a sequence</refpurpose>
<refpurpose>Insert an element to a sequence type column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -18,7 +18,8 @@
<methodparam><type>string</type><parameter>seq_element</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_col_insert</function> function is used to insert an element to a sequence type attribute in a requested location.
The <function>cubrid_col_insert</function> function is used to insert an
element to a sequence type attribute in a requested location.
</para>
</refsect1>
@ -32,7 +33,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance you want to work with.</para></listitem>
<listitem><para>OID of the instance you want to work with.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr_name</parameter></term>
@ -67,15 +68,61 @@
<programlisting role="php">
<![CDATA[
<?php
cubrid_seq_insert ($con, $oid, "tel", 1, "02-3430-1200");
cubrid_seq_insert ($con, $oid, "tel", 1, "02-3430-1300");
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c sequence(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "c");
var_dump($attr);
cubrid_seq_insert($conn, $oid, "c", 5, "44");
$attr = cubrid_col_get($conn, $oid, "c");
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(4) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
}
array(5) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
[4]=>
string(2) "44"
}
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-seq-put" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_seq_put</refname>
<refpurpose>Is used to update the content</refpurpose>
<refpurpose>Update the element value of sequence type column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -18,7 +18,8 @@
<methodparam><type>string</type><parameter>seq_element</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_seq_put</function> function is used to update the content of the requested element in a sequent type attribute.
The <function>cubrid_seq_put</function> function is used to update the
content of the requested element in a sequent type attribute using OID.
</para>
</refsect1>
@ -32,7 +33,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance you want to work with.</para></listitem>
<listitem><para>OID of the instance you want to work with.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr_name</parameter></term>
@ -67,15 +68,59 @@
<programlisting role="php">
<![CDATA[
<?php
cubrid_seq_put ($con, $oid, "tel", 1, "02-3430-1200");
cubrid_seq_put ($con, $oid, "tel", 2, "02-3430-1300");
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c sequence(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "c");
var_dump($attr);
cubrid_seq_put($conn, $oid, "c", 1, "111");
$attr = cubrid_col_get($conn, $oid, "c");
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(4) {
[0]=>
string(2) "11"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
}
array(4) {
[0]=>
string(3) "111"
[1]=>
string(2) "22"
[2]=>
string(2) "33"
[3]=>
string(3) "333"
}
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-set-add" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_set_add</refname>
<refpurpose>Is used to insert a single element</refpurpose>
<refpurpose>Insert a single element to set type column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -17,7 +17,9 @@
<methodparam><type>string</type><parameter>set_element</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_set_add</function> function is used to insert a single element to a set type attribute (set, multiset) you requested.
The <function>cubrid_set_add</function> function is used to insert a
single element to a set type attribute (set, multiset, sequence) you
requested.
</para>
</refsect1>
@ -31,7 +33,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance you want to work with.</para></listitem>
<listitem><para>OID of the instance you want to work with.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr_name</parameter></term>
@ -62,15 +64,57 @@
<programlisting role="php">
<![CDATA[
<?php
cubrid_set_add ($con, $oid, "friend", "James");
cubrid_set_add ($con, $oid, "friend", "Michael");
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_set_add($conn, $oid, "b", "4");
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
array(4) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
[3]=>
string(1) "4"
}
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-set-drop" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_set_drop</refname>
<refpurpose>Is used to delete an element</refpurpose>
<refpurpose>Delete an element from set type column using OID</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -17,7 +17,9 @@
<methodparam><type>string</type><parameter>set_element</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_set_drop</function> function is used to delete an element that you request from the given set type (set, multiset) attribute of the database.
The <function>cubrid_set_drop</function> function is used to delete an
element that you request from the given set type (set, multiset) attribute
of the database.
</para>
</refsect1>
@ -31,7 +33,7 @@
</varlistentry>
<varlistentry>
<term><parameter>oid</parameter></term>
<listitem><para>Oid of the instance you want to work with.</para></listitem>
<listitem><para>OID of the instance you want to work with.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>attr_name</parameter></term>
@ -62,11 +64,49 @@
<programlisting role="php">
<![CDATA[
<?php
cubrid_set_drop ($con, $oid, "friend", "James");
cubrid_set_drop ($con, $oid, "friend", "Michael");
$conn = cubrid_connect("localhost", 33000, "demodb");
@cubrid_execute($conn, "DROP TABLE foo");
cubrid_execute($conn, "CREATE TABLE foo(a int AUTO_INCREMENT, b set(int), c list(int), d char(10))");
cubrid_execute($conn, "INSERT INTO foo(a, b, c, d) VALUES(1, {1,2,3}, {11,22,33,333}, 'a')");
$req = cubrid_execute($conn, "SELECT * FROM foo", CUBRID_INCLUDE_OID);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$oid = cubrid_current_oid($req);
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_set_drop($conn, $oid, "b", "1");
$attr = cubrid_col_get($conn, $oid, "b");
var_dump($attr);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
array(2) {
[0]=>
string(1) "2"
[1]=>
string(1) "3"
}
]]>
</screen>
</example>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="function.cubrid-version" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_version</refname>
<refpurpose>Is used to get the CUBRID PHP modules version</refpurpose>
<refpurpose>Get the CUBRID PHP module's version</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,7 +14,8 @@
<void />
</methodsynopsis>
<para>
The <function>cubrid_version</function> function is used to get the CUBRID PHP modules version.
The <function>cubrid_version</function> function is used to get the CUBRID
PHP module's version.
</para>
</refsect1>
@ -26,7 +27,7 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Version information (eg. "1.2.0").
Version information (eg. "8.3.1.0001").
</para>
</refsect1>
@ -37,14 +38,61 @@
<programlisting role="php">
<![CDATA[
<?php
echo cubrid_version();
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
printf("\n");
$conn = cubrid_connect("localhost", 33088, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
CUBRID PHP Version: 8.3.1.0005
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT -1
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.3.1.0173
Client Info: 8.3.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>