#3312 [PHP] The PHP driver doesn't support shard_key sql hint in CUBRID Shard DB

open
nobody
None
5
2013-06-03
2013-06-03
Jira Trac
No

* Brief:
** The PHP driver doesn't support shard_key sql hint in CUBRID shard db

* Test Code (case - apis_551.zip):
{code}
?php

$shard_db = cubrid_connect('localhost', 45061, 'shard1', 'shard', 'shard123');
if (!$shard_db) { die(Connection error); }

sleep(3);

try{
// insert data to shard1
$stmt = cubrid_prepare($shard_db,'INSERT INTO tbl VALUES(/*+ shard_key */ ?)');
cubrid_bind($stmt, 1, 1);
cubrid_execute($stmt);

// insert data to shard2
$stmt = cubrid_prepare($shard_db,'INSERT INTO tbl VALUES(/*+ shard_key */ ?)');
cubrid_bind($stmt, 1, 32);
cubrid_execute($stmt);

// show data from shard1
$stmt = cubrid_prepare($shard_db,'SELECT * FROM tbl /*+ shard_id(0) */ ');
cubrid_execute($stmt);
while($data = cubrid_fetch_assoc($stmt))
{
echo shard1 data = .$data['id'].\n;
}

// show data from shard2
$stmt = cubrid_prepare($shard_db,'SELECT * FROM tbl /*+ shard_id(1) */ ');
cubrid_execute($stmt);
while($data = cubrid_fetch_assoc($stmt))
{
echo shard2 data = .$data['id'].\n;
}

}
catch(PDOException $e){
echoError: .$e-getMessage().;
}

?

* Expected Result: Shard1 data =1; Shard2 data = 32;
* Actual Result: Shard1 data = empty; Shard 2 data = 1, 32;

* Summary: The shard_key sql hint doesn't work correctly in PHP driver, but works correcly in other drviers such as JDBC

{code}

Discussion