PHP driver API reference
This page describes the public API of the PHP driver. Everything in the
CoraDB\Protocol namespace, and every member marked @internal, is internal and may change
without notice.
Opening a connection
Section titled “Opening a connection”use CoraDB\Connection;
$conn = Connection::open('coradb://dba:secret@localhost:33000/e-commerce');$conn = Connection::open(['host' => 'localhost', 'database' => 'e-commerce', 'user' => 'dba']);$conn = Connection::open('cci:CoraDB:localhost:33000:e-commerce:dba:secret:');$conn = Connection::open(new CoraDB\ConnectionOptions('localhost', 'e-commerce', 'dba', 'secret'));Connection::open() builds the options and connects. new Connection($options) builds an
unopened connection; call connect() to open it.
ConnectionOptions
Section titled “ConnectionOptions”Immutable connection settings. Timeouts are in seconds (float). null means no limit.
| Constructor parameter | Array / URL key | Default | Meaning |
|---|---|---|---|
$hosts |
host, port, althosts |
Required (array/URL: localhost, port 33000) |
One broker, or several tried in order. A string is parsed as a host:port,host2:port list. [ipv6]:port is accepted. |
$database |
database (or dbname) |
Required | Database name. |
$user |
user |
public |
|
$password |
password |
'' |
Hidden from var_dump() / print_r(). |
$connectTimeout |
connect_timeout |
30.0 |
Bounds the whole connect, across all hosts and retries. Each host gets a fair share of the time left (at least 2 s). |
$readTimeout |
read_timeout |
null |
Socket read timeout once connected. When it expires, the driver asks the broker to cancel the running query and closes the session. |
$queryTimeout |
query_timeout |
null |
Server-side limit for each query (used from milestone 2). |
$disconnectOnQueryTimeout |
disconnect_on_query_timeout |
false |
Drop the session when a query times out (milestone 2). |
$ssl |
ssl |
false |
Connect to an SSL broker (CUBRS handshake, then TLS 1.2+). Needs the openssl extension. |
$sslVerify |
ssl_verify |
false |
Verify the broker certificate and host name. Off by default, as in CCI, because brokers usually use self-signed certificates. |
$sslOptions |
ssl_options |
[] |
Extra PHP ssl stream context options (cafile, local_cert, ...). Not allowed in a URL. |
$connectRetries |
connect_retries |
0 |
Extra rounds over the host list after a failed first round. |
$loadBalance |
load_balance |
false |
Shuffle the host list on every connect. |
$autoCommit |
autocommit |
true |
Initial auto-commit mode. |
Building options
Section titled “Building options”| Method | Description |
|---|---|
new ConnectionOptions(hosts, database, ...) |
Named arguments are recommended. |
ConnectionOptions::fromArray(array $options) |
Keys from the table above. Values must have the exact type: booleans must be bool, timeouts int/float/null, the port int. An unknown key throws NO_PROPERTY. A wrong type throws INVALID_PROPERTY_VALUE. |
ConnectionOptions::fromUrl(string $url) |
coradb://[user[:password]@]host[:port][,host2[:port]]/database[?key=value&...]. User, password and database are URL-decoded. Query keys are the array keys (except host, database, user, password, ssl_options). Booleans accept true/false/1/0/yes/no/on/off. An empty timeout means null. |
ConnectionOptions::fromCciUrl(string $url, ?string $user = null, ?string $password = null) |
[cci:]CUBRID:host:port:database:user:password:[?property=value&...]. CoraDB is accepted instead of CUBRID. Non-empty $user/$password arguments replace those in the URL. Properties: altHosts, loadBalance, loginTimeout / connectTimeout and queryTimeout (milliseconds; 0 = none), disconnectOnQueryTimeout, useSSL. rcTime and the CCI logging properties are accepted and ignored. Any other property makes the URL invalid (INVALID_URL), as in CCI. |
Connection
Section titled “Connection”| Method | Returns | Description |
|---|---|---|
static open(ConnectionOptions|array|string $options) |
Connection |
Builds the options (a string is a coradb:// URL or a CCI URL) and connects. |
__construct(ConnectionOptions $options) |
An unopened connection. | |
connect() |
void |
Opens the session. Does nothing if it is already open. |
close() |
void |
Sends CON_CLOSE (best effort, at most 2 s) and closes the socket. The server rolls back an open transaction. connect() reopens. |
isConnected() |
bool |
True while a session is open. |
getOptions() |
ConnectionOptions |
|
getServerVersion() |
string |
Engine version, e.g. 1.0.0.1586. Cached per session. |
getProtocolVersion() |
int |
Negotiated CAS protocol version: the lower of the broker's and the driver's (9). |
getCasPid() |
int |
Process id of the CAS serving the session. |
getActiveHost() |
HostAddress |
Broker the session was opened on. |
getAutoCommit() / setAutoCommit(bool) |
As in CCI, changing the mode commits an open transaction. | |
inTransaction() |
bool |
True while the server reports an open transaction. |
commit() / rollback() |
void |
If the reply is lost, the commit may or may not have happened: ConnectionException is thrown with requestMayHaveRun() === true, and the connection reconnects. |
getIsolationLevel() / setIsolationLevel(IsolationLevel) |
||
getLockTimeout() / setLockTimeout(int $milliseconds) |
-1 waits forever. |
|
getDbParameter(DbParameter) / setDbParameter(DbParameter, int) |
As in CCI, an isolation level or lock timeout set through the connection is answered without asking the server. | |
ping(bool $reconnect = true) |
bool |
CHECK_CAS. With $reconnect, a lost session is replaced when no transaction was open. Returns false for a closed connection. |
cancel() |
void |
Asks the broker, on a separate socket, to interrupt the query running on this session. Use it from a signal handler or a shutdown function. |
prepare(string $sql, bool $includeOid = false) |
Statement |
Prepares a statement with ? markers. $includeOid makes rows carry their OID (Statement::getRowOid()). |
query(string $sql, array $parameters = [], int $executeFlags = 0) |
Statement |
Executes and returns the statement for fetching. Without parameters it prepares and executes in one round trip. Statement::EXEC_QUERY_ALL runs every statement of a multi-statement string. |
execute(string $sql, array $parameters = []) |
int |
Executes a statement, closes it, and returns the affected rows. |
executeBatch(list<string> $sqls) |
list<QueryResult> |
Runs several statements without parameters in one round trip. A failing statement doesn't stop the others; its QueryResult carries the error. |
escapeString(string $value) |
string |
Escapes a string for a single-quoted SQL literal, as CCI's cci_escape_string() does: ' becomes ''. When the server runs without no_backslash_escapes, NUL, CR, LF and \ are also escaped with a backslash. Prefer bound parameters. |
lastInsertId() |
?string |
The last AUTO_INCREMENT value generated in this session, as a decimal string; null when there is none. |
savepoint(string $name) / rollbackToSavepoint(string $name) |
void |
Savepoints in the current transaction. |
getSchema(SchemaType $type, ?string $name = null, ?string $attribute = null, int $flags = 0) |
Statement |
Schema information to fetch from. See Schema information. |
createLob(DataType $type = DataType::BLOB) |
Lob |
A new, empty BLOB or CLOB. See Large objects. |
getObject(), putObject(), getCollection(), ... |
Objects by OID and collection attributes. See Objects and collections. |
Lost sessions
Section titled “Lost sessions”When the session to the broker is lost outside a transaction, the next request opens a new session and is sent again, but only when it cannot have run on the old session:
- It was not completely sent; or
- It only reads state (
CHECK_CAS,GET_DB_VERSION,GET_DB_PARAMETER,PREPARE, ...).
Otherwise the request fails with ConnectionException, and requestMayHaveRun() returns
true. The connection is re-established and stays usable, but the driver never repeats a
write that may already have run.
A session lost during a transaction always fails, because the server rolled the transaction
back. The connection also remembers the loss: the next commit() rolls back whatever ran on the
new session and throws ConnectionException, so a partial transaction is never committed.
rollback() clears the condition. ping() never replaces a session that held a transaction.
The isolation level and lock timeout set through the connection are applied again on every new session, as CCI does.
Statements
Section titled “Statements”$stmt = $conn->prepare('SELECT id, name FROM product WHERE unit_price > ? AND units_in_stock < ?');$stmt->execute([100, 10]);while ($row = $stmt->fetch()) { echo $row['id'], ' ', $row['name'], PHP_EOL;}$stmt->close();
$conn->execute('UPDATE product SET units_in_stock = ? WHERE id = ?', [25, 10]); // returns the affected rows$rows = $conn->query('SELECT * FROM countries')->fetchAll(CoraDB\FetchMode::NUM);Parameters are sent typed (server-side binding), never spliced into the SQL text.
| Method | Returns | Description |
|---|---|---|
bindValue(int $position, mixed $value, ?DataType $type = null) |
void |
Binds a marker (1-based). Without a type, it is inferred from the value (see Data types). With a type, the value is converted on the client as CCI does: a string is accepted for every type. Throws BIND_INDEX for a bad position, TYPE_CONVERSION for a value that doesn't fit. |
execute(?array $parameters = null) |
void |
Executes. $parameters (a list, in marker order) replaces the bound values. Every marker needs a value (NOT_BIND). If the session was replaced since prepare(), the statement is prepared again first. |
clearParameters() |
void |
|
rowCount() |
int |
Rows of the result (SELECT and other row-returning statements), or affected rows (INSERT, UPDATE, DELETE). -1 before execution. |
executeArray(list<array> $rows, array<int, DataType> $types = []) |
list<QueryResult> |
Executes the statement once per row of values, in one round trip (EXECUTE_ARRAY). Types are inferred per value unless given by 1-based marker position. A failing row doesn't stop the others. rowCount() is the sum of the affected rows. |
getQueryResults() |
list<QueryResult> |
One entry per executed statement (or row of executeArray()). See QueryResult below. |
nextResult() |
bool |
Moves to the next result of a multi-statement execution (EXEC_QUERY_ALL). |
fetch(?FetchMode $mode = null) |
array|stdClass|false |
The next row, or false after the last one (or for a statement without rows). |
fetchAll(?FetchMode $mode = null) |
list |
The remaining rows. |
fetchColumn(int $column = 0) |
mixed |
One column (0-based) of the next row; false after the last row. |
seek(int $row) / tell() |
bool / int |
Moves the cursor so the next fetch() returns the row at a 0-based index; false when there is no such row. |
getRowOid() |
?Oid |
OID of the last fetched row (needs includeOid). |
columnCount(), getColumns(), getColumn(int $index) |
Result metadata: Column objects. |
|
getParameterCount(), getStatementType(), getSql() |
||
setFetchMode(FetchMode) |
Default mode of fetch(), fetchAll() and iteration (ASSOC). |
|
setFetchSize(int) |
Rows per FETCH round trip (100). | |
setMaxRows(int) |
Limits the rows of a SELECT (0: none). | |
setQueryTimeout(?float $seconds) |
Server-side limit per execution; defaults to the connection's query_timeout. The socket waits 10 s more for the server to report the timeout, unless disconnect_on_query_timeout is set. |
|
setExecuteFlags(int) |
Statement::EXEC_QUERY_ALL. |
|
close() / isClosed() |
Frees the server handle. Never fails. A statement is also closed when it is garbage-collected. |
QueryResult (readonly properties): type (StatementType), count (rows found or affected;
negative when the statement failed), oid (the OID of an inserted row, when reported),
errorCode and errorMessage (of a failed statement in a batch or array execution), and
failed().
A Statement is iterable: foreach ($stmt as $row) fetches rows with the default mode.
FetchMode: ASSOC (by column name; with duplicate names the last column wins), NUM (0-based
list), BOTH (both keys, position first), OBJECT (stdClass).
Column (readonly properties): name, type (DataType), elementType (collections),
charset, scale, precision, realName, table, nullable, defaultValue,
autoIncrement, uniqueKey, primaryKey, reverseIndex, reverseUnique, foreignKey,
shared, and typeName() (varchar, integer, set(varchar), ... as the CUBRID extension named
types).
Results are holdable, as in CCI: an open result survives the commit of its transaction. When a broker refuses holdable results, the connection falls back to non-holdable ones.
Transaction ends close results as cci_end_tran does. A rollback closes the results of the
rolled-back transaction, and a commit closes non-holdable results. Fetching from a closed
result, even rows already buffered, throws RESULT_SET_CLOSED. A broker without statement
pooling frees those handles itself (a rollback frees all of them), so the error is then
REQ_HANDLE. A statement whose handle was freed is prepared again on its next execute().
A failed execute() forgets the previous result.
Data types
Section titled “Data types”Fetched values:
| CoraDB type | PHP value |
|---|---|
| CHAR, VARCHAR (STRING), NCHAR, ENUM, JSON | string, the bytes as stored (no charset conversion). CHAR is blank-padded. |
| SMALLINT, INTEGER, BIGINT | int |
| FLOAT | float, rounded to the shortest decimal that reads back as the same 32-bit value (1.1, not 1.100000023841858) |
| DOUBLE, MONETARY | float |
| NUMERIC | string, exact ('12.50000') |
| DATE, TIME, TIMESTAMP, DATETIME | string: 2026-10-04, 13:05:59, 2026-10-04 13:05:59, 2026-10-04 13:05:59.123 (zero dates stay 0000-00-00) |
| TIMESTAMPTZ / LTZ, DATETIMETZ / LTZ | The same string followed by a space and the zone: 2026-10-04 13:05:59 Europe/Bucharest |
| BIT, BIT VARYING | string, raw bytes |
| SET, MULTISET, SEQUENCE | list of element values |
| OBJECT | Oid (@pageid|slotid|volid), or null for the empty OID |
| BLOB, CLOB | Lob, a handle to read the content from (see Large objects) |
| GRAPH_OBJECT | string, raw bytes |
| NULL | null |
Bound values without an explicit type:
| PHP value | Sent as |
|---|---|
null |
NULL |
bool |
INTEGER 1 / 0 |
int |
INTEGER, or BIGINT beyond 32 bits |
float |
DOUBLE |
string, Stringable |
VARCHAR |
DateTimeInterface |
DATETIME (millisecond precision) |
Oid |
OBJECT |
Lob |
BLOB / CLOB |
Collection::set(), multiset(), sequence() |
SET, MULTISET, SEQUENCE; the element type is given or inferred from the first non-null element. A MULTISET goes out as a SEQUENCE: the CAS rejects the MULTISET kind, and a MULTISET column converts a SEQUENCE, duplicates included. |
BackedEnum |
Its value |
array |
Not accepted without a collection type (use a Collection, or pass DataType::SET, ...) |
With an explicit DataType, strings are converted on the client as CCI does:
- Dates are
YYYY-MM-DDorYYYY/MM/DD; - Times are
HH:MM:SS[.fff], optionally followed byAM/PM; - The time-zone types take the zone after the time (
2026-10-04 13:05:59 Europe/Bucharest); - NUMERIC takes a decimal string;
- OBJECT takes
@p|s|v; - JSON takes text, or an array /
JsonSerializablethat is JSON-encoded.
Out-of-range integers are rejected rather than truncated. A DateTimeInterface keeps its zone for the time-zone types.
DataType::fromName('varchar') maps SQL type names (as cubrid_bind() accepted them) to types.
Batches
Section titled “Batches”$results = $conn->executeBatch([ "INSERT INTO countries VALUES ('ROU', 'Romania')", "UPDATE countries SET name = 'Czechia' WHERE code = 'CZE'",]);
$insert = $conn->prepare('INSERT INTO countries VALUES (?, ?)');$results = $insert->executeArray([['BGR', 'Bulgaria'], ['HUN', 'Hungary']]);foreach ($results as $i => $result) { if ($result->failed()) { printf("row %d: [%d] %s\n", $i, $result->errorCode, $result->errorMessage); }}Neither is ever sent again after a lost session, because part of it may have run.
Schema information
Section titled “Schema information”Connection::getSchema() returns a Statement whose rows describe the schema. Column names are
those of CCI and the CUBRID extension (NAME, TYPE, ATTR_NAME, DOMAIN, SCALE,
PRECISION, INDEXED, NON_NULL, SHARED, UNIQUE, DEFAULT, ATTR_ORDER, CLASS_NAME,
SOURCE_CLASS, IS_KEY, REMARKS, ... depending on the kind).
foreach ($conn->getSchema(SchemaType::ATTRIBUTE, 'orders') as $column) { echo $column['ATTR_NAME'], ' ', CoraDB\DataType::from($column['DOMAIN'])->name, PHP_EOL;}$tables = $conn->getSchema(SchemaType::TABLE, 'order%', flags: Connection::SCHEMA_CLASS_PATTERN)->fetchAll();$nameis the table,$attributethe column (forCROSS_REFERENCE, the foreign table).Connection::SCHEMA_CLASS_PATTERNandSCHEMA_ATTR_PATTERNmake themLIKEpatterns.DOMAINis the column'sDataTypecode, without the collection flag bits.
SchemaType: TABLE (1), VIEW (2), QUERY_SPEC, ATTRIBUTE, CLASS_ATTRIBUTE, METHOD,
CLASS_METHOD, METHOD_FILE, SUPERCLASS, SUBCLASS, CONSTRAINT, TRIGGER,
CLASS_PRIVILEGE, ATTR_PRIVILEGE, DIRECT_SUPER_CLASS, PRIMARY_KEY (16), IMPORTED_KEYS,
EXPORTED_KEYS, CROSS_REFERENCE, ATTR_WITH_SYNONYM (20): the values of CCI's
CCI_SCH_* and the extension's CUBRID_SCH_* constants.
Large objects
Section titled “Large objects”A BLOB or CLOB column is fetched as a Lob, a handle to content stored by the server. Its
content is read and written in pieces, at a current position.
$lob = $conn->createLob(DataType::BLOB);$lob->write(file_get_contents('photo.jpg'));$conn->execute('INSERT INTO photo (id, image) VALUES (?, ?)', [1, $lob]);
$lob = $conn->query('SELECT image FROM photo WHERE id = 1')->fetchColumn();$bytes = $lob->getContents();| Method | Returns | Description |
|---|---|---|
length() |
int |
Content length in bytes. |
read(int $length) |
string |
Up to $length bytes from the current position, which advances. Fewer at the end, '' past it. Large reads are split into 128 KiB requests. |
getContents() |
string |
From the current position to the end. |
write(string $data) |
int |
Writes at the current position and advances it; the length grows past the end. Sent in 128 KiB requests. |
seek(int $offset, int $whence = SEEK_SET) / tell() |
void / int |
Moves / reports the position. Negative positions throw INVALID_LOB_READ_POS. |
locator() |
string |
The server's locator (informational). |
type |
DataType |
BLOB or CLOB. |
A Lob belongs to the session it came from. After a reconnect, read() and write() throw
INVALID_LOB_HANDLE: fetch it again. LOB requests are never sent again after a lost session.
CLOB content is bytes in the database charset.
Objects and collections
Section titled “Objects and collections”CoraDB rows are objects with an OID. A statement prepared with includeOid: true reports each
row's OID (Statement::getRowOid()); OBJECT columns are fetched as Oid. Every method takes an
Oid or its string form ('@1|2|3').
| Method | Returns | Description |
|---|---|---|
getObject($oid, list<string> $attributes = []) |
array<string, mixed> |
Attribute values by name; all attributes when none are named. |
putObject($oid, array $values, array $types = []) |
void |
Sets attributes. Types are inferred as in bindValue() unless given by attribute name. |
getClassName($oid) |
string |
The table of the object. |
isInstance($oid) |
bool |
True when the object exists. |
dropObject($oid) |
void |
Deletes the object. |
lockRead($oid) / lockWrite($oid) |
void |
Shared / exclusive lock. |
getCollection($oid, string $attribute) |
list |
The elements of a SET, MULTISET or SEQUENCE attribute. |
getCollectionSize($oid, string $attribute) |
int |
|
addToSet($oid, $attribute, $value, ?DataType $type = null) / removeFromSet(...) |
void |
SET and MULTISET attributes. |
insertIntoSequence($oid, $attribute, int $index, $value, ?DataType $type = null) |
void |
Inserts before the 1-based $index. |
putIntoSequence($oid, $attribute, int $index, $value, ?DataType $type = null) |
void |
Replaces the element at $index. |
removeFromSequence($oid, $attribute, int $index) |
void |
The server returns OIDs only for tables that don't reuse them (ALTER TABLE t DONT_REUSE_OID).
Errors
Section titled “Errors”Every error is a CoraDB\Exception\CoraDBException (a RuntimeException).
| Member | Description |
|---|---|
getCode() |
The error number (see below). |
getMessage() |
The server's message, or the driver's standard message. |
getIndicator() |
-1 for an error reported by the CAS, -2 for one reported by the database engine, 0 for a driver error. |
isServerError() |
getIndicator() === -2. |
getFacility() |
Facility::DBMS, CAS, CCI (driver) or CLIENT (PHP API), as the extension's cubrid_error_code_facility() reported it. |
CoraDB\Exception\ConnectionException (a subclass) means the broker could not be reached,
the session was lost or timed out, or a reply can't be framed. The session that raised it is
closed. A broker or server that answers but refuses the session (a wrong password, an unknown
database) throws a plain CoraDBException with its error. Other hosts are tried only after
errors that mean a broker is unreachable or busy.
requestMayHaveRun() tells whether the failed request may have been executed.
Error numbers:
- Driver errors keep the CCI numbers that applications written for the CUBRID extension
already check.
CoraDB\ErrorCodehas the constants, for example:CONNECT(-20016): cannot connect;COMMUNICATION(-20004): connection lost or malformed reply;LOGIN_TIMEOUT(-20038);QUERY_TIMEOUT(-20039): read timeout;SSL_HANDSHAKE(-21047);CON_HANDLE(-20002): connection closed;INVALID_URL(-20030);NO_PROPERTY(-20033);INVALID_PROPERTY_VALUE(-20034).
- CAS errors are
ErrorCode::CAS_ER_*(-10000 ...). Codes from old brokers (-1000 ...) are converted. - Server errors keep the database engine's own number (e.g. -165 for a wrong password).
ErrorCode::message(int $code) returns the standard message of a driver, CAS or client code.
Enums and constants
Section titled “Enums and constants”| Type | Values |
|---|---|
IsolationLevel |
READ_COMMITTED (4), REPEATABLE_READ (5), SERIALIZABLE (6) |
DbParameter |
ISOLATION_LEVEL (1), LOCK_TIMEOUT (2), MAX_STRING_LENGTH (3), AUTO_COMMIT (4), NO_BACKSLASH_ESCAPES (5) |
Facility |
DBMS (1), CAS (2), CCI (3), CLIENT (4) |
HostAddress |
new HostAddress(host, port = 33000), HostAddress::parse('h:p'), HostAddress::parseList('h1,h2:p') |
Version::DRIVER |
The driver version, also reported to the broker. |
DataType |
The CoraDB types with their wire codes (STRING = 2, INT = 8, ...); fromName(), sqlName(), isCollection(), isLob(), isText(), isNumeric(), isTemporal(), hasTimeZone() |
StatementType |
SELECT (21), INSERT (20), UPDATE (22), DELETE (23), CALL (24), EVALUATE (14), CALL_SP (0x7e), ...; returnsRows() |
FetchMode |
NUM (1), ASSOC (2), BOTH (3), OBJECT (4), the values of CUBRID_NUM ... CUBRID_OBJECT |
Oid |
new Oid(pageId, slotId, volumeId), Oid::fromString('@1|2|3'), (string) $oid |
Collection |
Collection::set(array, ?DataType), multiset(), sequence() |
SchemaType |
See Schema information. |
The coradb_* functions
Section titled “The coradb_* functions”The coradb_* functions are the CUBRID extension's procedural API (php_cubrid7.c), renamed. An
application written for the extension switches by renaming cubrid_ to coradb_ and CUBRID_
to CORADB_, and loading Composer's vendor/autoload.php. They are a transitional layer over
the object-oriented API, and will be removed in a future major version: new code should use
CoraDB\Connection directly.
$conn = coradb_connect('localhost', 33000, 'e-commerce', 'dba', '');$req = coradb_prepare($conn, 'SELECT name, unit_price FROM product WHERE unit_price > ?');coradb_bind($req, 1, 200);coradb_execute($req);while ($row = coradb_fetch_assoc($req)) { echo $row['name'], PHP_EOL;}coradb_close_request($req);coradb_close($conn);All 93 functions and the two aliases (coradb_disconnect, coradb_close_prepare) are
available, with the extension's arguments and return values:
| Group | Functions |
|---|---|
| Connections | coradb_connect, coradb_pconnect, coradb_connect_with_url, coradb_pconnect_with_url, coradb_close, coradb_disconnect, coradb_ping, coradb_version, coradb_get_client_info, coradb_get_server_info, coradb_get_charset, coradb_client_encoding, coradb_list_dbs, coradb_db_name |
| Statements | coradb_prepare, coradb_bind, coradb_execute, coradb_query, coradb_unbuffered_query, coradb_batch_execute, coradb_next_result, coradb_affected_rows, coradb_insert_id, coradb_close_request, coradb_close_prepare, coradb_real_escape_string, coradb_get_query_timeout, coradb_set_query_timeout |
| Fetching | coradb_fetch, coradb_fetch_array, coradb_fetch_assoc, coradb_fetch_row, coradb_fetch_object, coradb_fetch_lengths, coradb_result, coradb_data_seek, coradb_move_cursor, coradb_current_oid, coradb_free_result, coradb_num_rows, coradb_num_cols, coradb_num_fields |
| Result metadata | coradb_column_names, coradb_column_types, coradb_field_name, coradb_field_table, coradb_field_type, coradb_field_flags, coradb_field_len, coradb_fetch_field, coradb_field_seek |
| Transactions and parameters | coradb_commit, coradb_rollback, coradb_get_autocommit, coradb_set_autocommit, coradb_get_db_parameter, coradb_set_db_parameter |
| Errors | coradb_error_code, coradb_error_code_facility, coradb_error_msg, coradb_errno, coradb_error |
| Schema | coradb_schema |
| Objects and collections | coradb_get, coradb_put, coradb_drop, coradb_is_instance, coradb_lock_read, coradb_lock_write, coradb_get_class_name, coradb_col_get, coradb_col_size, coradb_set_add, coradb_set_drop, coradb_seq_insert, coradb_seq_put, coradb_seq_drop |
| LOBs | coradb_lob2_new, coradb_lob2_bind, coradb_lob2_read, coradb_lob2_write, coradb_lob2_seek, coradb_lob2_seek64, coradb_lob2_tell, coradb_lob2_tell64, coradb_lob2_size, coradb_lob2_size64, coradb_lob2_import, coradb_lob2_export, coradb_lob2_close, coradb_lob_get, coradb_lob_size, coradb_lob_export, coradb_lob_send, coradb_lob_close |
The 42 constants are renamed the same way (CORADB_NUM, CORADB_ASSOC, CORADB_BOTH,
CORADB_OBJECT, CORADB_LOB, CORADB_INCLUDE_OID, CORADB_EXEC_QUERY_ALL, CORADB_ASYNC,
CORADB_CURSOR_FIRST / _CURRENT / _LAST, CORADB_SCH_*, CORADB_FACILITY_*,
CORADB_PARAM_*, CORADB_AUTOCOMMIT_*). TRAN_REP_CLASS_COMMIT_INSTANCE,
TRAN_REP_CLASS_REP_INSTANCE and TRAN_SERIALIZABLE keep their names, and are defined only if
the CUBRID extension has not defined them.
Behaviour kept from the extension
Section titled “Behaviour kept from the extension”- Errors: a failing function records the error and returns
false(or what the extension returned, such as-1fromcoradb_affected_rows()). It raises the warningError: <DBMS|CAS|CCI|CLIENT>, <code>, <message>.coradb_error_code(),coradb_error_msg()andcoradb_error_code_facility()report the last error of any link.coradb_errno()andcoradb_error()report the last error of one link. Every call clears both first. Error numbers are those of the extension: engine numbers, CAS (-10000...), CCI (-20000...) and client (-30000...). - Default link: functions whose link is optional use the last link opened.
coradb_connect()returns the open link it made earlier with the same arguments, unless$new_linkis true. - Cursor: the cursor is CCI's.
- After a SELECT the cursor is on row 1. After any other statement it is before the first row,
so
coradb_move_cursor()is needed to read the rows of a CALL. coradb_fetch*()reads the row under the cursor and then moves it on.coradb_move_cursor()positions are 1-based;coradb_data_seek()andcoradb_result()rows are 0-based.
- After a SELECT the cursor is on row 1. After any other statement it is before the first row,
so
- Values: fetched values are strings in CCI's text form.
- FLOAT is
%f; DOUBLE and MONETARY are%.16f(3.6000000000000001). - Dates and times are strings; DATETIME has milliseconds.
- BIT is uppercase hex; an OID is
@page|slot|volume. - A BLOB or CLOB is its locator, or a
Lob2handle withCORADB_LOB. - A collection column gives a list of element strings;
coradb_result()and the single attribute ofcoradb_get()give the{a, b}form. - SQL NULL is
null.
- FLOAT is
- Binding:
coradb_bind()sends a value as a string unless a type is given. The server converts the string, and with a type the driver converts it, as CCI does. Type names are the extension's (NUMBER,INT,DOUBLE,DATETIME, ...) and the SQL names (VARCHAR,INTEGER, ...).BITtakes a string of0/1.BLOB/CLOBtake a stream or a file name, whose content is stored.
- Affected rows and insert id: they follow the last statement executed on the link.
coradb_affected_rows()answers only after INSERT, UPDATE or DELETE.
Differences from the CUBRID extension
Section titled “Differences from the CUBRID extension”- Handles are objects: links, requests and LOBs are
CoraDB\Compat\Link,Request,Lob2andLegacyLobobjects, not resources, sois_resource()returns false. Each one exposes the object-oriented API:$link->connection,$request->statement,$lob2->lob. - Warnings are E_USER_WARNING: userland code cannot raise E_WARNING. Error handlers that
filter on
E_WARNINGneedE_USER_WARNINGas well. - Argument errors throw: wrong argument types and closed handles throw
TypeError, as the extension does on PHP 8. When no link is open and none is given, the function warnsNo CoraDB link opened yetand returns false. - Persistent connections:
coradb_pconnect()andcoradb_pconnect_with_url()open an ordinary connection that is not reused by a later pconnect call. The extension for PHP 7 and later did the same: it never kept connections across requests. - No truncation: strings are not cut at a NUL byte, and
BITvalues keep their zero bytes. - Fetched LOBs stay valid:
Lob2handles stay usable after the fetch loop ends, while the extension invalidated the last row's handles. They become invalid only when their link is closed. - Credentials in URLs:
coradb_connect_with_url()without a user and password uses those in the URL. The extension ignored them and connected with an empty user. - More type names:
coradb_column_types()andcoradb_field_type()name the newer types (json,timestamptz, ...) where the extension saidunknown. - Number formatting: the Oracle-compatible number formatting that CCI applies on version 12
brokers with
oracle_compat_number_behavioris not applied. - Messages: driver and CAS errors carry CCI's messages, with CoraDB in place of CUBRID (for
example
Cannot connect to CoraDB CAS). Server messages don't end with CCI's[CAS INFO-...]suffix. - Warning location: a warning's file and line are the driver's (where it raises the warning), not the calling script's.
- Argument checks come first: an argument error is thrown before the call clears the last
error, so
coradb_error_code()still reports the error before it. The extension cleared it first. - An explicit null link means the default link, like an omitted one. On PHP 8 the extension threw a TypeError for null.
coradb_lob2_close()closes the handle: using the handle afterwards throws a TypeError. The extension's handle stayed usable.