Fixed pecl/ibm_db2 Driver and Connection to run smoothly against the complete test-suite (depending on a c-patch to the extension though)
This commit is contained in:
parent
024b2bab91
commit
b7cac8c310
@ -71,18 +71,12 @@ class Db2Connection implements \Doctrine\DBAL\Driver\Connection
|
|||||||
{
|
{
|
||||||
$stmt = $this->prepare($statement);
|
$stmt = $this->prepare($statement);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
return $stmt;
|
return $stmt->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
function lastInsertId($name = null)
|
function lastInsertId($name = null)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1';
|
return db2_last_insert_id($this->_conn);
|
||||||
if ($stmt = $this->query($sql)) {
|
|
||||||
if ($col = $stmt->fetchColumn()) {
|
|
||||||
return $col;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function beginTransaction()
|
function beginTransaction()
|
||||||
|
@ -25,6 +25,8 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
|
|||||||
{
|
{
|
||||||
private $_stmt = null;
|
private $_stmt = null;
|
||||||
|
|
||||||
|
private $_bindParam = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
|
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
|
||||||
* @var <type>
|
* @var <type>
|
||||||
@ -54,7 +56,7 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
|
|||||||
*/
|
*/
|
||||||
function bindValue($param, $value, $type = null)
|
function bindValue($param, $value, $type = null)
|
||||||
{
|
{
|
||||||
return $this->bindParam($param, $variable, $type);
|
return $this->bindParam($param, $value, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +83,9 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
|
|||||||
*/
|
*/
|
||||||
function bindParam($column, &$variable, $type = null)
|
function bindParam($column, &$variable, $type = null)
|
||||||
{
|
{
|
||||||
if (!$type && isset(self::$_typeMap[$type])) {
|
$this->_bindParam[$column] =& $variable;
|
||||||
|
|
||||||
|
if ($type && isset(self::$_typeMap[$type])) {
|
||||||
$type = self::$_typeMap[$type];
|
$type = self::$_typeMap[$type];
|
||||||
} else {
|
} else {
|
||||||
$type = DB2_CHAR;
|
$type = DB2_CHAR;
|
||||||
@ -90,6 +94,7 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
|
|||||||
if (!db2_bind_param($this->_stmt, $column, "variable", DB2_PARAM_IN, $type)) {
|
if (!db2_bind_param($this->_stmt, $column, "variable", DB2_PARAM_IN, $type)) {
|
||||||
throw new Db2Exception(db2_stmt_errormsg());
|
throw new Db2Exception(db2_stmt_errormsg());
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,6 +108,8 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_bindParam = array();
|
||||||
|
db2_free_result($this->_stmt);
|
||||||
$ret = db2_free_stmt($this->_stmt);
|
$ret = db2_free_stmt($this->_stmt);
|
||||||
$this->_stmt = false;
|
$this->_stmt = false;
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -171,12 +178,17 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$retval = true;
|
/*$retval = true;
|
||||||
if ($params !== null) {
|
if ($params !== null) {
|
||||||
$retval = @db2_execute($this->_stmt, $params);
|
$retval = @db2_execute($this->_stmt, $params);
|
||||||
} else {
|
} else {
|
||||||
$retval = @db2_execute($this->_stmt);
|
$retval = @db2_execute($this->_stmt);
|
||||||
|
}*/
|
||||||
|
if ($params === null) {
|
||||||
|
ksort($this->_bindParam);
|
||||||
|
$params = array_values($this->_bindParam);
|
||||||
}
|
}
|
||||||
|
$retval = @db2_execute($this->_stmt, $params);
|
||||||
|
|
||||||
if ($retval === false) {
|
if ($retval === false) {
|
||||||
throw new Db2Exception(db2_stmt_errormsg());
|
throw new Db2Exception(db2_stmt_errormsg());
|
||||||
@ -260,7 +272,7 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
|
|||||||
function fetchColumn($columnIndex = 0)
|
function fetchColumn($columnIndex = 0)
|
||||||
{
|
{
|
||||||
$row = $this->fetch(\PDO::FETCH_NUM);
|
$row = $this->fetch(\PDO::FETCH_NUM);
|
||||||
if (!$row && isset($row[$columnIndex])) {
|
if ($row && isset($row[$columnIndex])) {
|
||||||
return $row[$columnIndex];
|
return $row[$columnIndex];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -282,7 +282,7 @@ class Db2Platform extends AbstractPlatform
|
|||||||
*/
|
*/
|
||||||
public function getCurrentDateSQL()
|
public function getCurrentDateSQL()
|
||||||
{
|
{
|
||||||
return 'current date';
|
return 'VALUES CURRENT DATE';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,7 +292,7 @@ class Db2Platform extends AbstractPlatform
|
|||||||
*/
|
*/
|
||||||
public function getCurrentTimeSQL()
|
public function getCurrentTimeSQL()
|
||||||
{
|
{
|
||||||
return 'current time';
|
return 'VALUES CURRENT TIME';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,10 +300,11 @@ class Db2Platform extends AbstractPlatform
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
/*public function getCurrentTimestampSQL()
|
|
||||||
|
public function getCurrentTimestampSQL()
|
||||||
{
|
{
|
||||||
return 'current timestamp';
|
return "VALUES CURRENT TIMESTAMP";
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain DBMS specific SQL code portion needed to set an index
|
* Obtain DBMS specific SQL code portion needed to set an index
|
||||||
@ -437,11 +438,6 @@ class Db2Platform extends AbstractPlatform
|
|||||||
return "SESSION." . $tableName;
|
return "SESSION." . $tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCurrentTimestampSQL()
|
|
||||||
{
|
|
||||||
return "VALUES CURRENT TIMESTAMP";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function modifyLimitQuery($query, $limit, $offset = null)
|
public function modifyLimitQuery($query, $limit, $offset = null)
|
||||||
{
|
{
|
||||||
if ($limit === null && $offset === null) {
|
if ($limit === null && $offset === null) {
|
||||||
|
@ -122,7 +122,7 @@ class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
public function testUpdateAs()
|
public function testUpdateAs()
|
||||||
{
|
{
|
||||||
$dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1';
|
$dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1';
|
||||||
$this->_em->createQuery($dql)->getResult();
|
$this->_em->createQuery($dql)->execute();
|
||||||
|
|
||||||
$this->assertTrue(count($this->_em->createQuery(
|
$this->assertTrue(count($this->_em->createQuery(
|
||||||
'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')->getResult()) > 0);
|
'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')->getResult()) > 0);
|
||||||
|
@ -48,6 +48,8 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa
|
|||||||
// Get user
|
// Get user
|
||||||
$user = $uRep->findOneById($user->getId());
|
$user = $uRep->findOneById($user->getId());
|
||||||
|
|
||||||
|
$this->assertNotNull($user, "Has to return exactly one entry.");
|
||||||
|
|
||||||
$this->assertFalse($user->getGroups()->isInitialized());
|
$this->assertFalse($user->getGroups()->isInitialized());
|
||||||
|
|
||||||
// Check groups
|
// Check groups
|
||||||
@ -89,6 +91,8 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa
|
|||||||
|
|
||||||
// Association should not exist
|
// Association should not exist
|
||||||
$user2 = $this->_em->find(get_class($user), $user->getId());
|
$user2 = $this->_em->find(get_class($user), $user->getId());
|
||||||
|
|
||||||
|
$this->assertNotNull($user2, "Has to return exactly one entry.");
|
||||||
$this->assertEquals(0, $user2->getGroups()->count());
|
$this->assertEquals(0, $user2->getGroups()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user