|
Posted by M. Trausch on 11/16/05 03:44
Hello everyone,
I've been searching for a little bit on Google and the PHP documentation
and I still haven't found an answer as to how to accomplish this
particular task. I'm attempting to create a (nearly complete) database
abstraction layer by using a set of classes, and then have the
application that uses this layer just create an instance of one of these
objects to manipulate the database.
The problem that I'm having is that I can't really find a way to define
a constant that will make the determination of which class the
application wants to use without using switch all over the place or
something, and I'm thinking that there has to be a neater solution then
that.
For example, what I'd like to do is have a config.php that contains a
line like:
define(DATABASE_CLASS, MySQL_5_Database);
The problem is that it doesn't seem to work as expected. When I attempt
to use this in real code:
$db = new DATABASE_CLASS($user, $pwd, $dbName);
I get the error:
Fatal error: Class 'DATABASE_CLASS' not found in
C:\wwwroot\eclipse\workspace\cpim\index.php on line 21
Is there some way of using more C-style preprocessor substitution, to
make something like this possible? I can't seem to find out if there is
or isn't, because I can't seem to find anything about it on the Web. I
am using PHP 5, as well.
Thanks,
Mike
--
Strip the somewhat obvious trash from the header to send e-mail.
Navigation:
[Reply to this message]
|