CUBRID Functions (PDO_CUBRID)

Einführung

PDO_CUBRID is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to CUBRID databases.

Hinweis:

Current version of PDO_CUBRID doesn't support persistent connection now.

Installation

To build the PDO_CUBRID extension, the CUBRID DBMS must be installed on the same system as PHP. PDO_CUBRID is a » PECL extension, so follow the instructions in Installation of PECL extensions to install the PDO_CUBRID extension. Issue the configure command to point to the location of your CUBRID base dir as follows:

   $ ./configure --with-pdo-cubrid=/path/to/CUBRID[,shared]
The configure command defaults to the value of the CUBRID environment variable.

Eine DLL-Datei für diese PECL-Erweiterung steht derzeit nicht zur Verfügung. Weitere Details finden Sie im Abschnitt zum Kompilieren für Windows. Detailed information about installation on Linux and Windows manually, please read build-guide.html in PECL package CUBRID for reference.

Features

PDO_CUBRID Features
Feature Description
Scrollable cursors PDO_CUBRID supports scrollable cursors. The default cursor type is forward only, and you can use parameter driver_options in PDO::prepare() to change cursor type.
Timeout PDO_CUBRID supports sql statement execution timeout setting; You can use PDO::setAttribute() to set timeout value.
Autocommit_mode and Transaction PDO_CUBRID supports both autocommit_mode and transaction, and autocommit_mode is enabled by default. You can use PDO::setAttribute() to change its state.

If you use PDO::beginTransaction() to begin a transaction, it will disable autocommit_mode automatically and restore it after PDO::commit() or PDO::rollBack(). Note that before disabling the autocommit_mode, any pending work is automatically committed.

Multiple SQL Statements PDO_CUBRID supports Multiple SQL statements. Multiple SQL statements are separated by semicolons (;)
Schema Information PDO_CUBRID implements a function PDO::cubrid_schema() to get schema information.
LOBs 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:

Beispiel #1 Insert LOBs in CUBRID PDO

<?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$fpPDO::PARAM_LOB);
$ret $stmt->execute();
?>

Beispiel #2 Fetch LOBs in CUBRID PDO

<?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]);
?>

Column meta The PDOStatement::getColumnMeta() in CUBRID PDO will return an associative array containing the following values:
  • type
  • name
  • table
  • def
  • precision
  • scale
  • not_null
  • auto_increment
  • unique_key
  • multiple_key
  • primary_key
  • foreign_key
  • reverse_index
  • reverse_unique
Collection Data Type PDO_CUBRID supports SET/MULTISET/SEQUENCE data type. If you don't specify data type, the default data type is char,for example:

Beispiel #3 Insert set in CUBRID PDO with default data type.

<?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$dataPDO::PARAM_NULL);
$ret $stmt->execute();
var_Dump($ret);
?>

Beispiel #4 Specify data type when insert set in CUBRID PDO

<?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$data0,0,"int");
$ret $stmt->execute();
var_Dump($ret);
?>

CUBRID Bind Data Types:(The fifth parameter of PDOStatement::bindParam):
  • CHAR
  • STRING
  • NCHAR
  • VARNCHAR
  • BIT
  • VARBIT
  • NUMERIC
  • NUMBER
  • INT
  • SHORT
  • BIGINT
  • MONETARY
  • FLOAT
  • DOUBLE
  • DATE
  • TIME
  • DATETIME
  • TIMESTAMP

Vordefinierte Konstanten

Die folgenden Konstanten werden von diesem Treiber definiert und sind nur verfügbar, wenn die Erweiterung entweder in PHP einkompiliert oder dynamisch zur Laufzeit geladen wurde. Darüber hinaus sind diese Konstanten treiberspezifisch und sollten nur mit diesem Treiber benutzt werden. Treiberspezifische Attribute mit einem anderen Treiber zu nutzen, kann zu unerwarteten Ergebnissen führen. Wenn der Code mit verschiedenen Treibern funktioniert, kann PDO::getAttribute() verwendet werden, um mit PDO::ATTR_DRIVER_NAME den aktuellen Treiber zu ermitteln.

The following constants can be used when setting the database attribute. They can be passed to PDO::getAttribute() or PDO::setAttribute().

PDO::CUBRID attribute flags
Constant Description
PDO::CUBRID_ATTR_ISOLATION_LEVEL Transaction isolation level for the database connection.
PDO::CUBRID_ATTR_LOCK_TIMEOUT Transaction timeout in seconds.
PDO::CUBRID_ATTR_MAX_STRING_LENGTH Read only. The maximum string length for bit, varbit, char, varchar, nchar, nchar varying data types when using CUBRID PDO API.

The following constants can be used when setting the transaction isolation level. They can be passed to PDO::getAttribute() or returned by PDO::setAttribute().

PDO::CUBRID isolation level flags
Constant Description
PDO::TRAN_COMMIT_CLASS_UNCOMMIT_INSTANCE The lowest isolation level (1). A dirty, non-repeatable or phantom read may occur for the tuple and a non-repeatable read may occur for the table as well.
PDO::TRAN_COMMIT_CLASS_COMMIT_INSTANCE A relatively low isolation level (2). A dirty read does not occur, but non-repeatable or phantom read may occur.
PDO::TRAN_REP_CLASS_UNCOMMIT_INSTANCE The default isolation of CUBRID (3). A dirty, non-repeatable or phantom read may occur for the tuple, but repeatable read is ensured for the table.
PDO::TRAN_REP_CLASS_COMMIT_INSTANCE A relatively low isolation level (4). A dirty read does not occur, but non-repeatable or phantom read may.
PDO::TRAN_REP_CLASS_REP_INSTANCE A relatively high isolation level (5). A dirty or non-repeatable read does not occur, but a phantom read may.
PDO::TRAN_SERIALIZABLE The highest isolation level (6). Problems concerning concurrency (e.g. dirty read, non-repeatable read, phantom read, etc.) do not occur.

The following constants can be used when getting schema information. They can be passed to PDO::cubrid_schema().

PDO::CUBRID schema flags
Constant Description
PDO::CUBRID_SCH_TABLE Get name and type of table in CUBRID.
PDO::CUBRID_SCH_VIEW Get name and type of view in CUBRID.
PDO::CUBRID_SCH_QUERY_SPEC Get the query definition of view.
PDO::CUBRID_SCH_ATTRIBUTE Get the attributes of table column.
PDO::CUBRID_SCH_TABLE_ATTRIBUTE Get the attributes of table.
PDO::CUBRID_SCH_METHOD Get the instance method. The instance method is a method called by a class instance. It is used more often than the class method because most operations are executed in the instance.
PDO::CUBRID_SCH_TABLE_METHOD Get the class method. The class method is a method called by a class object. It is usually used to create a new class instance or to initialize it. It is also used to access or update class attributes.
PDO::CUBRID_SCH_METHOD_FILE Get the information of the file where the method of the table is defined.
PDO::CUBRID_SCH_SUPER_TABLE Get the name and type of table which table inherites attributes from.
PDO::CUBRID_SCH_SUB_TABLE Get the name and type of table which inherites attributes from this table.
PDO::CUBRID_SCH_CONSTRAINT Get the table constraints.
PDO::CUBRID_SCH_TRIGGER Get the table triggers.
PDO::CUBRID_SCH_TABLE_PRIVILEGE Get the privilege information of table.
PDO::CUBRID_SCH_COL_PRIVILEGE Get the privilege information of column.
PDO::CUBRID_SCH_DIRECT_SUPER_TABLE Get the direct super table of table.
PDO::CUBRID_SCH_PRIMARY_KEY Get the table primary key.
PDO::CUBRID_SCH_IMPORTED_KEYS Get imported keys of table.
PDO::CUBRID_SCH_EXPORTED_KEYS Get exported keys of table.
PDO::CUBRID_SCH_CROSS_REFERENCE Get reference relationship of tow tables.

Inhaltsverzeichnis

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Berechnungen durchführen

Hallo liebe Forenmitglieder, meine erste frage ist zum Aufbau meiner kleinen Berechnungswebseite, nichts kommerzielles, soll nur eine Anwendung f ...

Geschrieben von matze511 am 21.04.2024 21:42:37
Forum: PHP Developer Forum
Professioneller Webentwickler & Webdesigner

Of course, here is the translation: Hello, Thank you for your interest in the long-term project. Your extensive skills and experience in web dev ...

Geschrieben von Athelstan am 15.04.2024 09:25:39
Forum: Jobgesuche
Wir stellen unsere SEO-Agentur vor

Hallo In der heutigen digitalen Welt war es für Unternehmen noch nie so einfach, ihre Reichweite weltweit zu vergrößern. Wenn Sie außerhalb I ...

Geschrieben von thomasmuller am 14.04.2024 07:18:33
Forum: User stellen sich vor
Spielplan für 4 Gruppen zu je 6 Teams auf 2 Feldern

Hallöchen zusammen, ich versuche derzeit unseren Excel-Spielplan in PHP zu überführen. Eigentlich bin ich auch shon fertig - wenn da nicht dies ...

Geschrieben von derH0st am 11.04.2024 15:58:37
Forum: PHP Developer Forum