lol Dormilich, in almost every answer I get from you there is this sentence :
from the OOP point-of-view, it does not make sense
i may have completely missed the OOP concepts or maybe you are not enough open minded. probably it's the first option.. but consider this, and then tell me if I missed something:
there is by default a fetch mode wich is FETCH_BOTH (I think)(it's FETCH_ASSOC and FETCH_NUM).
the point is that the default fetch mode does not satisfy my needs, because i use 99% of the time the FETCH_ASSOC, there for i would like to change the default value to fit my needs.
If i have to change the fetch mode to FETCH_ASSOC every time i create a pdoStatement (with a wrapper) then it makes
n changes (given
n is the number of pdoStatement instances created).
However if i change it once from the bootstraper and then ocasionally when i need the other fetch mode (FETCH_NUM) i change it from the pdoStatement instance, i would only get
1n/100 which is a good improvement.
so whenever there is a default value that gets replicated over every instance, with the right to change the instance value, i think it would make sense to make that default property
static, to allow the programmer to change that property if desired like this :
-
class pdoStatement
-
{
-
private static $_defaultFetchMode = pdo::FETCH_BOTH;
-
-
private $_fetchMode;
-
-
public function __construct()
-
{
-
//set the instance fetchMode from default fetch mode
-
$this->setFetchMode(self::$_defaultFetchMode);
-
}
-
-
public function setFetchMode($fetchMode)
-
{
-
//ensure fetch mode is supported
-
self::isSupportedFetchMode($fetchMode);
-
//fetch mode supported
-
$this->_fetchMode = $fetchMode;
-
}
-
-
static public function setDefaultFetchMode($fetchMode)
-
{
-
//ensure fetch mode is supported
-
self::isSupportedFetchMode($fetchMode);
-
//fetch mode supported
-
self::$_defaultFetchMode = $fetchMode;
-
}
-
-
static public function isSupportedFetchMode($fetchMode)
-
{
-
switch ($fetchMode) {
-
case FETCH_BOTH;
-
break;
-
case FETCH_ASSOC;
-
break;
-
case FETCH_NUM;
-
break;
-
case etc.
-
break
-
default;
-
throw new pdoStatement_Exception('Error : fetch mode not supported');
-
break;
-
}
-
}
-
}
it saves some resources and time to write a wrapper.
we could even write the second option i gave, to set the fetchMode from the pdo class. That seems to make sense too because the pdo class creates pdoStatments, so it could call pdoStatement::setFetchMode() before returning the pdoStatement. (i wont code it, you get what i mean)
anyway I appreciate your answer and if you see any mistake in my point, i would be pleased if you made some remarks.