Commit b7cac8c3 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Fixed pecl/ibm_db2 Driver and Connection to run smoothly against the complete...

Fixed pecl/ibm_db2 Driver and Connection to run smoothly against the complete test-suite (depending on a c-patch to the extension though)
parent 024b2bab
......@@ -71,18 +71,12 @@ class Db2Connection implements \Doctrine\DBAL\Driver\Connection
{
$stmt = $this->prepare($statement);
$stmt->execute();
return $stmt;
return $stmt->rowCount();
}
function lastInsertId($name = null)
{
$sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1';
if ($stmt = $this->query($sql)) {
if ($col = $stmt->fetchColumn()) {
return $col;
}
}
return false;
return db2_last_insert_id($this->_conn);
}
function beginTransaction()
......
......@@ -25,6 +25,8 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
{
private $_stmt = null;
private $_bindParam = array();
/**
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
* @var <type>
......@@ -54,7 +56,7 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
*/
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)
{
if (!$type && isset(self::$_typeMap[$type])) {
$this->_bindParam[$column] =& $variable;
if ($type && isset(self::$_typeMap[$type])) {
$type = self::$_typeMap[$type];
} else {
$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)) {
throw new Db2Exception(db2_stmt_errormsg());
}
return true;
}
/**
......@@ -103,6 +108,8 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
return false;
}
$this->_bindParam = array();
db2_free_result($this->_stmt);
$ret = db2_free_stmt($this->_stmt);
$this->_stmt = false;
return $ret;
......@@ -171,12 +178,17 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
return false;
}
$retval = true;
/*$retval = true;
if ($params !== null) {
$retval = @db2_execute($this->_stmt, $params);
} else {
$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) {
throw new Db2Exception(db2_stmt_errormsg());
......@@ -260,7 +272,7 @@ class Db2Statement implements \Doctrine\DBAL\Driver\Statement
function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(\PDO::FETCH_NUM);
if (!$row && isset($row[$columnIndex])) {
if ($row && isset($row[$columnIndex])) {
return $row[$columnIndex];
}
return false;
......
......@@ -282,7 +282,7 @@ class Db2Platform extends AbstractPlatform
*/
public function getCurrentDateSQL()
{
return 'current date';
return 'VALUES CURRENT DATE';
}
/**
......@@ -292,7 +292,7 @@ class Db2Platform extends AbstractPlatform
*/
public function getCurrentTimeSQL()
{
return 'current time';
return 'VALUES CURRENT TIME';
}
/**
......@@ -300,10 +300,11 @@ class Db2Platform extends AbstractPlatform
*
* @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
......@@ -437,11 +438,6 @@ class Db2Platform extends AbstractPlatform
return "SESSION." . $tableName;
}
public function getCurrentTimestampSQL()
{
return "VALUES CURRENT TIMESTAMP";
}
public function modifyLimitQuery($query, $limit, $offset = null)
{
if ($limit === null && $offset === null) {
......
......@@ -122,7 +122,7 @@ class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testUpdateAs()
{
$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(
'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')->getResult()) > 0);
......
......@@ -28,7 +28,7 @@ class DefaultValuesTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'romanb';
$this->_em->persist($user);
$this->_em->flush();
$this->_em->clear();
$this->_em->clear();
$userId = $user->id; // e.g. from $_REQUEST
$user2 = $this->_em->getReference(get_class($user), $userId);
......
......@@ -47,7 +47,9 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa
// Get user
$user = $uRep->findOneById($user->getId());
$this->assertNotNull($user, "Has to return exactly one entry.");
$this->assertFalse($user->getGroups()->isInitialized());
// Check groups
......@@ -89,6 +91,8 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa
// Association should not exist
$user2 = $this->_em->find(get_class($user), $user->getId());
$this->assertNotNull($user2, "Has to return exactly one entry.");
$this->assertEquals(0, $user2->getGroups()->count());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment