2009年9月3日星期四

Re: [fw-db] A question on coding design used for DB Statements.

Mamsaac,


> method MUST be implemented, but there's no enforcing of it. I can see that
> extending classes (the one that I checked the most was
> Zend_Db_Statement_Pdo) do implement the method.

Ironically, I've recently noticed the same thing and create

http://framework.zend.com/issues/browse/ZF-7708

fixed in:

http://framework.zend.com/code/changelog/Standard_Library/standard/trunk/library/Zend/Db?cs=17856

This tends to happen with software that grows organically. I am sure it
was on oversight.

> So, I wonder why _prepare is not declared in Zend_Db_Statement as "abstract
> protected function _prepare($sql);".

Since there is the possibility that people are implementing either the
interface and/or extending the base class Zend_Db_Statement, I did not
want to create a possible BC break in their code. So, instead of an
abstract method that is required to be implemented, the base
implementation now has an empty method called _prepare() that could be
overridden in the extending classes. This is the safest route to go so
that there is no BC break in cases where people have extended the base
class.

-ralph

没有评论: