mirror of
https://github.com/macintoshplus/doc-en.git
synced 2026-03-24 08:52:18 +01:00
Rewrite this table as a series of sections that describes each feature. And do some slight markup fixes at the same time. However, these docs are in a sad state and not up to our standard which is somewhat usual with PECL extension docs
337 lines
8.7 KiB
XML
337 lines
8.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<reference xml:id="ref.pdo-cubrid" xmlns="http://docbook.org/ns/docbook"><?phpdoc extension-membership="pecl" ?>
|
|
<title>CUBRID Functions (PDO_CUBRID)</title>
|
|
<titleabbrev>CUBRID (PDO)</titleabbrev>
|
|
<partintro>
|
|
|
|
<section xml:id="pdo-cubrid.intro">&reftitle.intro;
|
|
<para>
|
|
PDO_CUBRID is a driver that implements the
|
|
<link linkend="intro.pdo">PHP Data Objects (PDO) interface</link>
|
|
to enable access from PHP to CUBRID databases.
|
|
</para>
|
|
<note><para>
|
|
Current version of PDO_CUBRID doesn't support persistent connection now.
|
|
</para></note>
|
|
</section>
|
|
|
|
<!-- Information found in configure.xml -->
|
|
&reference.pdo-cubrid.configure;
|
|
|
|
<section xml:id="ref.pdo-cubrid.features">
|
|
<title>PDO_CUBRID Features</title>
|
|
|
|
<section>
|
|
<title>Scrollable cursors</title>
|
|
<simpara>
|
|
PDO_CUBRID supports scrollable cursors. The default cursor type is
|
|
forward only, and you can use parameter driver_options in
|
|
<methodname>PDO::prepare</methodname> to change cursor type.
|
|
</simpara>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Timeout</title>
|
|
<simpara>
|
|
PDO_CUBRID supports sql statement execution timeout setting;
|
|
You can use <methodname>PDO::setAttribute</methodname> to set timeout value.
|
|
</simpara>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Autocommit_mode and Transaction</title>
|
|
|
|
<simpara>
|
|
PDO_CUBRID supports both autocommit_mode and transaction, and
|
|
autocommit_mode is enabled by default. You can use
|
|
<methodname>PDO::setAttribute</methodname> to change its state.
|
|
</simpara>
|
|
|
|
<simpara>
|
|
If you use <methodname>PDO::beginTransaction</methodname> to begin a
|
|
transaction, it will disable autocommit_mode automatically and
|
|
restore it after <methodname>PDO::commit</methodname> or
|
|
<methodname>PDO::rollBack</methodname>.
|
|
</simpara>
|
|
|
|
<note>
|
|
<simpara>
|
|
Prior do disabling autocommit_mode
|
|
any pending work is automatically committed.
|
|
</simpara>
|
|
</note>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Multiple SQL Statements</title>
|
|
|
|
<simpara>
|
|
PDO_CUBRID supports Multiple SQL statements.
|
|
Multiple SQL statements are separated by semicolons (<literal>;</literal>).
|
|
</simpara>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Schema Information</title>
|
|
|
|
<simpara>
|
|
PDO_CUBRID implements <methodname>PDO::cubrid_schema</methodname>
|
|
to get schema information.
|
|
</simpara>
|
|
</section>
|
|
|
|
<section>
|
|
<title>LOBs</title>
|
|
|
|
<simpara>
|
|
PDO_CUBRID supports BLOB/CLOB data type. The LOB in PDO is
|
|
represented as a stream, so you can insert LOBs by binding a stream,
|
|
and get LOBs by reading a stream returned by CUBRID PDO.
|
|
For example:
|
|
</simpara>
|
|
|
|
<example>
|
|
<title>Insert LOBs in CUBRID PDO</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$fp = fopen('lob_test.png', 'rb');
|
|
|
|
$sql_stmt = "INSERT INTO lob_test(name, content) VALUES('lob_test.png', ?)";
|
|
|
|
$stmt = $dbh->prepare($sql_stmt);
|
|
$ret = $stmt->bindParam(1, $fp, PDO::PARAM_LOB);
|
|
$ret = $stmt->execute();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Fetch LOBs in CUBRID PDO</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$sql_stmt = "SELECT content FROM lob_test WHERE name='lob_test.png'";
|
|
|
|
$stmt = $dbh->prepare($sql_stmt);
|
|
$stmt->execute();
|
|
$result = $stmt->fetch(PDO::FETCH_NUM);
|
|
|
|
header("Content-Type: image/png");
|
|
fpassthru($result[0]);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Column meta</title>
|
|
|
|
<para>
|
|
The <methodname>PDOStatement::getColumnMeta</methodname> in CUBRID PDO
|
|
will return an associative array containing the following values:
|
|
<simplelist>
|
|
<member>type</member>
|
|
<member>name</member>
|
|
<member>table</member>
|
|
<member>def</member>
|
|
<member>precision</member>
|
|
<member>scale</member>
|
|
<member>not_null</member>
|
|
<member>auto_increment</member>
|
|
<member>unique_key</member>
|
|
<member>multiple_key</member>
|
|
<member>primary_key</member>
|
|
<member>foreign_key</member>
|
|
<member>reverse_index</member>
|
|
<member>reverse_unique</member>
|
|
</simplelist>
|
|
</para>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Collection Data Type</title>
|
|
|
|
<simpara>
|
|
PDO_CUBRID supports SET/MULTISET/SEQUENCE data type.
|
|
If you don't specify data type, the default data type is char.
|
|
For example:
|
|
</simpara>
|
|
|
|
<example>
|
|
<title>Insert set in CUBRID PDO with default data type.</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$conn_str ="cubrid:dbname=demodb;host=localhost;port=33000";
|
|
$cubrid_pdo = new PDO($conn_str, 'dba', '');
|
|
|
|
$cubrid_pdo->exec("DROP TABLE if exists test_tbl");
|
|
$cubrid_pdo->exec("CREATE TABLE test_tbl (col_1 SET(VARCHAR))");
|
|
|
|
$sql_stmt_insert = "INSERT INTO test_tbl VALUES (?);";
|
|
$stmt = $cubrid_pdo->prepare($sql_stmt_insert);
|
|
$data = array("abc","def","ghi");
|
|
$ret = $stmt->bindParam(1, $data, PDO::PARAM_NULL);
|
|
$ret = $stmt->execute();
|
|
var_Dump($ret);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Specify data type when insert set in CUBRID PDO</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$conn_str ="cubrid:dbname=demodb;host=localhost;port=33000";
|
|
$cubrid_pdo = new PDO($conn_str, 'dba', '');
|
|
|
|
$cubrid_pdo->exec("DROP TABLE if exists test_tbl");
|
|
$cubrid_pdo->exec("CREATE TABLE test_tbl (col_1 SET(int))");
|
|
|
|
$sql_stmt_insert = "INSERT INTO test_tbl VALUES (?);";
|
|
$stmt = $cubrid_pdo->prepare($sql_stmt_insert);
|
|
$data = array(1,2,3,4);
|
|
$ret = $stmt->bindParam(1, $data, 0,0,"int");
|
|
$ret = $stmt->execute();
|
|
var_Dump($ret);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<para>
|
|
CUBRID Bind Data Types for the fifth parameter of
|
|
<methodname>PDOStatement::bindParam</methodname>:
|
|
<simplelist>
|
|
<member>CHAR</member>
|
|
<member>STRING</member>
|
|
<member>NCHAR</member>
|
|
<member>VARNCHAR</member>
|
|
<member>BIT</member>
|
|
<member>VARBIT</member>
|
|
<member>NUMERIC</member>
|
|
<member>NUMBER</member>
|
|
<member>INT</member>
|
|
<member>SHORT</member>
|
|
<member>BIGINT</member>
|
|
<member>MONETARY</member>
|
|
<member>FLOAT</member>
|
|
<member>DOUBLE</member>
|
|
<member>DATE</member>
|
|
<member>TIME</member>
|
|
<member>DATETIME</member>
|
|
<member>TIMESTAMP</member>
|
|
</simplelist>
|
|
</para>
|
|
</section>
|
|
</section>
|
|
|
|
<!-- Information found in constants.xml -->
|
|
&reference.pdo-cubrid.constants;
|
|
|
|
</partintro>
|
|
|
|
<refentry xml:id="ref.pdo-cubrid.connection">
|
|
<refnamediv>
|
|
<refname>PDO_CUBRID DSN</refname>
|
|
<refpurpose>Connecting to CUBRID databases</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<para>
|
|
The PDO_CUBRID Data Source Name (DSN) is composed of the following elements, delimited by semicolons:
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>DSN prefix</term>
|
|
<listitem>
|
|
<para>
|
|
The DSN prefix is <userinput>cubrid:</userinput>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><literal>host</literal></term>
|
|
<listitem>
|
|
<para>
|
|
The hostname on which the database server resides.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><literal>port</literal></term>
|
|
<listitem>
|
|
<para>
|
|
The port on which the database server is running.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><literal>dbname</literal></term>
|
|
<listitem>
|
|
<para>
|
|
The name of the database.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
When you estalish the connection to CUBRID, you should give username and
|
|
password except DSN.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>PDO_CUBRID DSN examples</title>
|
|
<para>
|
|
The following example shows a PDO_CUBRID DSN for connecting to a CUBRID database:
|
|
<programlisting><![CDATA[
|
|
cubrid:host=localhost;port=33000;dbname=demodb
|
|
]]>
|
|
</programlisting>
|
|
</para>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
&reference.pdo-cubrid.entities.PDO;
|
|
|
|
</reference>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|