posted 2 years ago in CUBRID Life category by Esen Sagynov
We are happy to announce that we have updated our CUBRID PHP and PDO drivers to roll out loads of improvements and bug fixes. The latest releases can be installed from CUBRID and PDO_CUBRID PECL packages. Below is a list of improvements which landed in cubrid-9.1.0.0004 and pdo_cubrid-9.1.0.0003 versions.
- Connection parameters support.
- Improved CUBRID database sharding support.
- Collection data types support.
- Removed dynamic CUBRID CCI API dependency.
- Improved LOB data support.
- Improved documentation.
- Other minor improvements.
Connection parameters support
[APIS-580] Now both PHP and PDO drivers support all connection parameters supported by the underlying CCI API. When connecting to a CUBRID Broker, you can pass a list of various options like a list of alternative hosts which can be used either in HA environment to provide seamless failover functionality or in non-HA environment to provide driver level load balancing functionality. These are espectially useful in CUBRID SHARD environment.
Here is an example in PHP:
$conn = cubrid_connect($host, $port, $db, $user, $password, $createNewLink, "altHosts=192.168.0.2:33000,192.168.0.3:33000&rcTime=600");
Alternatively, connect with a URL:
$conn = cubrid_connect_with_url("CUBRID:localhost:33000:demodb:user:password:?login_timeout=100&altHosts=192.168.0.2:33000,192.168.0.3:33000&rcTime=600");
Or in PDO:
$db = new PDO("cubrid:dbname=demodb;host=localhost;port=33000", $user, $password, array("altHosts"=>"192.168.0.2:33000","rcTime"=>"600"));
Improved CUBRID database sharding support
We fixed a bug in PHP driver [APIS-562] which prevented
DELETE queries from being executed by
cubrid_execute() function in CUBRID SHARD environment.
Collection data types support
[APIS-555] Now PHP and PDO drivers provide native support for CUBRID collection data types like
SEQUENCE. There are multiple ways to insert an array of values into a collection data type column.
Inserting an array of integers
$sql_stmt_insert = "INSERT INTO set_tbl_int VALUES (?);"; $data = array(123,456,789); $stmt = $dbh->prepare($sql_stmt_insert); // Provide the data type of elements as a third parameter. $ret = $stmt->bindParam(1, $data, PDO::PARAM_INT); $ret = $stmt->execute();
Inserting an array of strings
To insert an array of strings, set the PDO data type to
NULL. This will tell PDO not to perform any conversion.
$sql_stmt_insert = "INSERT INTO set_tbl_str VALUES (?);"; $data = array("abc","def","ghi"); $stmt = $cubrid_pdo->prepare($sql_stmt_insert); // When inserting an array of string, set the data type to NULL. // This will tell PDO not to perform any conversion. $ret = $stmt->bindParam(1, $data, PDO::PARAM_NULL); $ret = $stmt->execute();
Alternatively, setting integer as a PDO data type will work as well. PDO will still keep the values as strings.
$sql_stmt_insert = "INSERT INTO set_tbl_str VALUES (?);"; $data = array("abc","def","ghi"); $stmt = $cubrid_pdo->prepare($sql_stmt_insert); $ret = $stmt->bindParam(1, $data, PDO::PARAM_INT); $ret = $stmt->execute();
The third way to insert an array of string is to specify the CUBRID data type in the fifth parameter as shown below.
$sql_stmt_insert = "INSERT INTO set_tbl_str VALUES (?);"; $data = array("abc","def","ghi"); $stmt = $cubrid_pdo->prepare($sql_stmt_insert); $ret = $stmt->bindParam(1, $data, 0, 0, "varchar"); $ret = $stmt->execute();
- Notice that
PDO::PARAM_ARRAYcannot be used because PDO does not support it.
PDO::PARAM_STRalso should not be used because PDO will throw an error that an array to string conversion is not allowed.
Removed dynamic CUBRID CCI API dependency
[APIS-559] Since this release CUBRID PHP and PDO drivers do not have dynamic dependency on CUBRID CCI driver. Instead we now compile PHP and PDO driver together with CCI source code. This allows to install PHP and PDO drivers on environments where CUBRID Server is not installed. This is one more step closer to provide a platform independent PHP and PDO drivers.
Improved LOB data support
- [APIS-556] - We fixed a LOB related bug in
cubrid_fetch()function which tried to allocate 4 billion bytes.
- [APIS-364] - Also fixed a bug which affected Windows users when a user tried to export LOB data from a database which was successfully imported from a fie prior to export.
- [APIS-553] - Manual page for
cubrid_close_request()should be edited.
- [APIS-554] -
cubrid_connect_with_url()example does not have updated connection url.
- [APIS-557] -
cubrid_lob2_seek64example does not work properly.
- [APIS-558] - incorrect documentation.
- [APIS-584] - Some 'Example' codes about the driver in php.net are somewhat confused.
- [APIS-596] - The 'test_lob' table which is not created initially may lead some misunderstandings.
Other minor improvements
- [APIS-120] - Return value is not correct when passing a date parameter to cubrid_bind method.
- [APIS-121] - Return value is not false when passing a invalid time to cubrid_bind method.
- [APIS-358] - Create table failed when using default timestamp '2038-01-19 12:14:07'.
- [APIS-513] - CAS error code is not expected in Windows.
- [APIS-560] - Cannot load PHP API 9.1.0.0003 in CentOS 5.6: undefined symbol: pthread_create in Unknown on line 0.
- [APIS-583] - The cubrid_get_class_name() function throws a warning if select data from a system table.
- [APIS-586] - cubrid_bind() doesn't work properly when insert bit data.
- [APIS-587] - cubrid_bind() doesn't support select bit data from a prepared statement.
- [APIS-549] - Warnings during PHP/PDO API build via PECL.
In the next version we will focus on improving Mac OS X support. The current release was a preparation for this. After removing the dynamic CCI dependency we can easily compile our PHP ad PDO drivers on Mac OS X as well.
Stay tuned for further updates!