Commit c9de54b4 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Changed Connection::execute() to Connection::executeQuery() as defined as a todo.

parent 7af6aa1d
......@@ -316,7 +316,7 @@ class Connection implements DriverConnection
*/
public function fetchRow($statement, array $params = array())
{
return $this->execute($statement, $params)->fetch(PDO::FETCH_ASSOC);
return $this->executeQuery($statement, $params)->fetch(PDO::FETCH_ASSOC);
}
/**
......@@ -329,7 +329,7 @@ class Connection implements DriverConnection
*/
public function fetchArray($statement, array $params = array())
{
return $this->execute($statement, $params)->fetch(PDO::FETCH_NUM);
return $this->executeQuery($statement, $params)->fetch(PDO::FETCH_NUM);
}
/**
......@@ -343,7 +343,7 @@ class Connection implements DriverConnection
*/
public function fetchColumn($statement, array $params = array(), $colnum = 0)
{
return $this->execute($statement, $params)->fetchColumn($colnum);
return $this->executeQuery($statement, $params)->fetchColumn($colnum);
}
/**
......@@ -524,7 +524,7 @@ class Connection implements DriverConnection
*/
public function fetchAll($sql, array $params = array())
{
return $this->execute($sql, $params)->fetchAll(PDO::FETCH_ASSOC);
return $this->executeQuery($sql, $params)->fetchAll(PDO::FETCH_ASSOC);
}
/**
......@@ -549,10 +549,9 @@ class Connection implements DriverConnection
* @param string $query The SQL query to execute.
* @param array $params The parameters to bind to the query, if any.
* @return Doctrine\DBAL\Driver\Statement The executed statement.
* @todo Rename to executeQuery ?
* @internal PERF: Directly prepares a driver statement, not a wrapper.
*/
public function execute($query, array $params = array(), $types = array())
public function executeQuery($query, array $params = array(), $types = array())
{
$this->connect();
......@@ -589,7 +588,7 @@ class Connection implements DriverConnection
public function project($query, array $params = array(), Closure $function)
{
$result = array();
$stmt = $this->execute($query, $params);
$stmt = $this->executeQuery($query, $params);
while ($row = $stmt->fetch()) {
$result[] = $function($row);
......
......@@ -128,7 +128,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$columnNameSql = "SELECT attnum, attname FROM pg_attribute
WHERE attrelid={$row['indrelid']} AND attnum $colNumbersSql ORDER BY attnum ASC;";
$stmt = $this->_conn->execute($columnNameSql);
$stmt = $this->_conn->executeQuery($columnNameSql);
$indexColumns = $stmt->fetchAll();
// required for getting the order of the columns right.
......
......@@ -80,7 +80,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
$indexBuffer = array();
// fetch primary
$stmt = $this->_conn->execute( "PRAGMA TABLE_INFO ('$tableName')" );
$stmt = $this->_conn->executeQuery( "PRAGMA TABLE_INFO ('$tableName')" );
$indexArray = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach($indexArray AS $indexColumnRow) {
if($indexColumnRow['pk'] == "1") {
......@@ -101,7 +101,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
$idx['primary'] = false;
$idx['non_unique'] = $tableIndex['unique']?false:true;
$stmt = $this->_conn->execute( "PRAGMA INDEX_INFO ( '{$keyName}' )" );
$stmt = $this->_conn->executeQuery( "PRAGMA INDEX_INFO ( '{$keyName}' )" );
$indexArray = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ( $indexArray as $indexColumnRow ) {
......
......@@ -157,7 +157,7 @@ class RunSqlTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em');
if (preg_match('/^select/i', $arguments['sql'])) {
$stmt = $em->getConnection()->execute($arguments['sql']);
$stmt = $em->getConnection()->executeQuery($arguments['sql']);
$resultSet = $stmt->fetchAll(\Doctrine\DBAL\Connection::FETCH_ASSOC);
} else {
$resultSet = $em->getConnection()->executeUpdate($arguments['sql']);
......
......@@ -429,7 +429,7 @@ class StandardEntityPersister
{
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc);
$params = array_values($criteria);
$stmt = $this->_conn->execute($sql, $params);
$stmt = $this->_conn->executeQuery($sql, $params);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
......@@ -447,7 +447,7 @@ class StandardEntityPersister
$sql = $this->_getSelectEntitiesSQL($id);
$params = array_values($id);
$stmt = $this->_conn->execute($sql, $params);
$stmt = $this->_conn->executeQuery($sql, $params);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
......@@ -530,7 +530,7 @@ class StandardEntityPersister
$sql = $this->_getSelectEntitiesSQL($criteria);
$params = array_values($criteria);
$stmt = $this->_conn->execute($sql, $params);
$stmt = $this->_conn->executeQuery($sql, $params);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
......@@ -553,7 +553,7 @@ class StandardEntityPersister
$owningAssoc = $this->_class->associationMappings[$coll->getMapping()->mappedBy];
$sql = $this->_getSelectEntitiesSQL($criteria, $owningAssoc, $assoc->orderBy);
$params = array_values($criteria);
$stmt = $this->_conn->execute($sql, $params);
$stmt = $this->_conn->executeQuery($sql, $params);
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
$coll->hydrateAdd($this->_createEntity($result));
}
......@@ -571,7 +571,7 @@ class StandardEntityPersister
{
$sql = $this->_getSelectManyToManyEntityCollectionSQL($assoc, $criteria);
$params = array_values($criteria);
$stmt = $this->_conn->execute($sql, $params);
$stmt = $this->_conn->executeQuery($sql, $params);
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
$coll->hydrateAdd($this->_createEntity($result));
}
......
......@@ -43,6 +43,6 @@ class SingleSelectExecutor extends AbstractSqlExecutor
public function execute(Connection $conn, array $params, array $types)
{
return $conn->execute($this->_sqlStatements, $params, $types);
return $conn->executeQuery($this->_sqlStatements, $params, $types);
}
}
......@@ -85,7 +85,7 @@ class SchemaTool
$conn = $this->_em->getConnection();
foreach ($createSchemaSql as $sql) {
$conn->execute($sql);
$conn->executeQuery($sql);
}
}
......@@ -482,7 +482,7 @@ class SchemaTool
$conn = $this->_em->getConnection();
foreach ($dropSchemaSql as $sql) {
$conn->execute($sql);
$conn->executeQuery($sql);
}
}
......@@ -570,7 +570,7 @@ class SchemaTool
$conn = $this->_em->getConnection();
foreach ($updateSchemaSql as $sql) {
$conn->execute($sql);
$conn->executeQuery($sql);
}
}
......
......@@ -27,13 +27,12 @@ class AbstractManyToManyAssociationTestCase extends \Doctrine\Tests\OrmFunctiona
protected function _countForeignKeys($firstId, $secondId)
{
return count($this->_em->getConnection()
->execute("SELECT {$this->_firstField}
FROM {$this->_table}
WHERE {$this->_firstField}=?
AND {$this->_secondField}=?",
array($firstId, $secondId))
->fetchAll());
return count($this->_em->getConnection()->executeQuery("
SELECT {$this->_firstField}
FROM {$this->_table}
WHERE {$this->_firstField} = ?
AND {$this->_secondField} = ?
", array($firstId, $secondId))->fetchAll());
}
public function assertCollectionEquals(Collection $first, Collection $second)
......
......@@ -120,8 +120,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
// Check that the foreign key has been set
$userId = $this->_em->getConnection()->execute("SELECT user_id FROM cms_addresses WHERE id=?",
array($address->id))->fetchColumn();
$userId = $this->_em->getConnection()->executeQuery(
"SELECT user_id FROM cms_addresses WHERE id=?", array($address->id)
)->fetchColumn();
$this->assertTrue(is_numeric($userId));
$this->_em->clear();
......@@ -158,8 +159,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
// Check that the link in the association table has been deleted
$count = $this->_em->getConnection()->execute("SELECT COUNT(*) FROM cms_users_groups",
array())->fetchColumn();
$count = $this->_em->getConnection()->executeQuery(
"SELECT COUNT(*) FROM cms_users_groups", array()
)->fetchColumn();
$this->assertEquals(0, $count);
}
......@@ -182,8 +184,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
// Check that there are indeed 10 links in the association table
$count = $this->_em->getConnection()->execute("SELECT COUNT(*) FROM cms_users_groups",
array())->fetchColumn();
$count = $this->_em->getConnection()->executeQuery(
"SELECT COUNT(*) FROM cms_users_groups", array()
)->fetchColumn();
$this->assertEquals(10, $count);
$user->groups->clear();
......@@ -192,8 +195,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
// Check that the links in the association table have been deleted
$count = $this->_em->getConnection()->execute("SELECT COUNT(*) FROM cms_users_groups",
array())->fetchColumn();
$count = $this->_em->getConnection()->executeQuery(
"SELECT COUNT(*) FROM cms_users_groups", array()
)->fetchColumn();
$this->assertEquals(0, $count);
}
......@@ -220,8 +224,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
// Check that there are just 2 phonenumbers left
$count = $this->_em->getConnection()->execute("SELECT COUNT(*) FROM cms_phonenumbers",
array())->fetchColumn();
$count = $this->_em->getConnection()->executeQuery(
"SELECT COUNT(*) FROM cms_phonenumbers", array()
)->fetchColumn();
$this->assertEquals(2, $count); // only 2 remaining
}
......
......@@ -51,7 +51,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
// Manually update/increment the version so we can try and save the same
// $test and make sure the exception is thrown saying the record was
// changed or updated since you read it
$this->_conn->execute('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id));
$this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id));
// Now lets change a property and try and save it again
$test->whatever = 'ok';
......@@ -80,7 +80,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
// Manually update/increment the version so we can try and save the same
// $test and make sure the exception is thrown saying the record was
// changed or updated since you read it
$this->_conn->execute('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id));
$this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id));
// Now lets change a property and try and save it again
$test->name = 'WHATT???';
......@@ -109,7 +109,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
// Manually update/increment the version so we can try and save the same
// $test and make sure the exception is thrown saying the record was
// changed or updated since you read it
$this->_conn->execute('UPDATE optimistic_standard SET version = ? WHERE id = ?', array(2, $test->id));
$this->_conn->executeQuery('UPDATE optimistic_standard SET version = ? WHERE id = ?', array(2, $test->id));
// Now lets change a property and try and save it again
$test->name = 'WHATT???';
......@@ -139,7 +139,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
// Manually increment the version datetime column
$format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString();
$this->_conn->execute('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', array(date($format, strtotime($test->version->format($format)) + 3600), $test->id));
$this->_conn->executeQuery('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', array(date($format, strtotime($test->version->format($format)) + 3600), $test->id));
// Try and update the record and it should throw an exception
$test->name = 'Testing again';
......
......@@ -162,7 +162,10 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
}
public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature) {
$foreignKey = $this->_em->getConnection()->execute('SELECT product_id FROM ecommerce_features WHERE id=?', array($feature->getId()))->fetchColumn();
$foreignKey = $this->_em->getConnection()->executeQuery(
'SELECT product_id FROM ecommerce_features WHERE id=?',
array($feature->getId())
)->fetchColumn();
$this->assertEquals($value, $foreignKey);
}
}
......@@ -116,7 +116,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
}
public function assertForeignKeyIs($value, ECommerceCategory $child) {
$foreignKey = $this->_em->getConnection()->execute('SELECT parent_id FROM ecommerce_categories WHERE id=?', array($child->getId()))->fetchColumn();
$foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', array($child->getId()))->fetchColumn();
$this->assertEquals($value, $foreignKey);
}
}
......@@ -144,7 +144,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
}
public function assertCartForeignKeyIs($value) {
$foreignKey = $this->_em->getConnection()->execute('SELECT customer_id FROM ecommerce_carts WHERE id=?', array($this->cart->getId()))->fetchColumn();
$foreignKey = $this->_em->getConnection()->executeQuery('SELECT customer_id FROM ecommerce_carts WHERE id=?', array($this->cart->getId()))->fetchColumn();
$this->assertEquals($value, $foreignKey);
}
}
......@@ -110,7 +110,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
}
public function assertForeignKeyIs($value) {
$foreignKey = $this->_em->getConnection()->execute('SELECT mentor_id FROM ecommerce_customers WHERE id=?', array($this->customer->getId()))->fetchColumn();
$foreignKey = $this->_em->getConnection()->executeQuery('SELECT mentor_id FROM ecommerce_customers WHERE id=?', array($this->customer->getId()))->fetchColumn();
$this->assertEquals($value, $foreignKey);
}
......
......@@ -99,7 +99,10 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
}
public function assertForeignKeyIs($value) {
$foreignKey = $this->_em->getConnection()->execute('SELECT shipping_id FROM ecommerce_products WHERE id=?', array($this->product->getId()))->fetchColumn();
$foreignKey = $this->_em->getConnection()->executeQuery(
'SELECT shipping_id FROM ecommerce_products WHERE id=?',
array($this->product->getId())
)->fetchColumn();
$this->assertEquals($value, $foreignKey);
}
}
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