Issues

ZF-6185: Zend_Db missing an implementation of PDO::exec()

Description

This prevents Zend_Db from being a drop in replacement for PDO applications.

Comments

patch for Zend/Db/Adapter/Abstract.php.

contains missing function exec()

unittests for /Zend/Db/Adapter/TestCommon.php

unittests for exec() method.

Just for my information, why don't you want to use the query() method? (except to retrieve number of rows)

With you proposition, there is also no profiling.

Two reasons: 1) for certain queries you dont need a result set and therefore creating the statement instance is needless overhead 2) exec() returns the number of affected rows, that I would have to get with another method call if I were to use query()

Also semantically it is important to know that this is not a select query, for example if one would want to run an explain automatically. These are also usually not the type of queries that need profiling and if they do .. though I invite you to add profiling support.

Finally the lack of the exec() method prevents Zend_Db to work as a drop in replacement for PDO projects.

Thanks Lukas.

Ralph, I can apply the patch and test it against all PDO adapters with limitation mentions above => no profiling.

Your opinion?

Patch applied to trunk and 1.8 release branch.

Modified in SVN15204

Tested with all adapters:


PHPUnit 3.3.15 by Sebastian Bergmann.

Zend Framework - Zend_Db
 Zend_Db_Adapter_Pdo_MssqlTest
 ...

 Zend_Db_Adapter_Pdo_MysqlTest
 ...

 Zend_Db_Adapter_Pdo_OciTest
 ...

 Zend_Db_Adapter_Pdo_PgsqlTest
 ..F

 Zend_Db_Adapter_Pdo_SqliteTest
 ...

Time: 10 seconds

There was 1 failure:

1) testAdapterExecModifiedNone(Zend_Db_Adapter_Pdo_PgsqlTest)
Expected exec() to return zero affected rows; got 1
Failed asserting that <<<