1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision: 331310 $ -->
<reference xml:id="ref.pdo-cubrid" xmlns="http://docbook.org/ns/docbook">
<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>Features</title>
<table>
<title>PDO_CUBRID Features</title>
<tgroup cols="2">
<thead>
<row>
<entry>Feature</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Scrollable cursors</entry>
<entry>
PDO_CUBRID supports scrollable cursors. The default cursor type is
forward only, and you can use parameter driver_options in
<function>PDO::prepare</function> to change cursor type.
</entry>
</row>
<row>
<entry>Timeout</entry>
<entry>PDO_CUBRID supports sql statement execution timeout setting;
You can use <function>PDO::setAttribute</function> to set timeout value.</entry>
</row>
<row>
<entry>Autocommit_mode and Transaction</entry>
<entry>
PDO_CUBRID supports both autocommit_mode and transaction, and
autocommit_mode is enabled by default. You can use
<function>PDO::setAttribute</function> to change its state.
<para>
If you use <function>PDO::beginTransaction</function> to begin a
transaction, it will disable autocommit_mode automatically and
restore it after <function>PDO::commit</function> or
<function>PDO::rollBack</function>. Note that before disabling the
autocommit_mode, any pending work is automatically committed.
</para>
</entry>
</row>
<row>
<entry>Multiple SQL Statements</entry>
<entry>PDO_CUBRID supports Multiple SQL statements. Multiple SQL
statements are separated by semicolons (;)</entry>
</row>
<row>
<entry>Schema Information</entry>
<entry>PDO_CUBRID implements a function
<function>PDO::cubrid_schema</function> to get schema information.
</entry>
</row>
<row>
<entry>LOBs</entry>
<entry>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:
<para>
<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>
</para>
<para>
<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>
</para>
</entry>
</row>
<row>
<entry>Column meta</entry>
<entry>
The <function>PDOStatement::getColumnMeta</function> 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>
</entry>
</row>
<row>
<entry>Collection Data Type</entry>
<entry>PDO_CUBRID supports SET/MULTISET/SEQUENCE data type. If you don't specify data type,
the default data type is char,for example:
<para>
<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>
</para>
<para>
<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:(The fifth parameter of PDOStatement::bindParam):
<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>
</entry>
</row>
</tbody>
</tgroup>
</table>
</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
-->
|