MDB 2.0 question
| From: | Lukas Smith | Date: | Fri, 18 Jul 2003 16:39:12 +0000 |
| Subject: | MDB 2.0 question | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-18388@lists.php.net to get a copy of this message | ||
Hi,
ok I have a little question about MDB 2.0 and I am interested in your
opinions. Basically I want to move some functionality into separate
classes that will be loaded as class properties.
Actually this is already done in the management methods in MDB 1.x.
However I am not sure if I really like how its done there.
Let me explain:
In MDB 1.x the createDatabase method looks like this for mysql:
function createDatabase(&$db, $name)
{
if (MDB::isError($result = $db->connect())) {
return($result);
}
$query = 'CREATE DATABASE '.$name;
if(MDB::isError($db->query($query))) {
return($db->mysqlRaiseError());
}
return(MDB_OK);
}
I am thinking of changing this to be like the following:
function createDatabase($name)
{
if (MDB::isError($result = $this->db->connect())) {
return($result);
}
$query = 'CREATE DATABASE '.$name;
if(MDB::isError($this->db->query($query))) {
return($this->db->mysqlRaiseError());
}
return(MDB_OK);
}
I am not sure if there is really a huge benefit to either version. The
first may have the advantage that things could be called statically.
However I don't really see where the benefit to this would be. I also
don't know if there is any performance difference (haven't benchmarked
it). In the latter case it would lead to a recursive references
($db->manager->db would be a reference to $db). Anyhow I like the last
version better though since the interface of the method is more compact.
In MDB 1.x this wasn't such a big deal as all method calls where
"proxied" from the core class. That is you would never call the
createDatabase method directly. Instead you would call
$db->createDatabase($name) and this method would in turn "proxy" that
call to the instance of the manager class.
Hope it is clear what I mean.
So what do you all think?
Regards,
Lukas Smith
smith@backendmedia.com
_______________________________
BackendMedia
www.backendmedia.com
berlin@backendmedia.com
Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin
Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07