If you do it that way, you will also have to construct an object and
return it from that function.  By including the class definitions
within a function, they will only be available within that function.
You will have to use the function as a factory for building objects.
In most cases I could only imagine an entire application using one or
the other, not both, so what I would do is include one or the other in
a application-wide config include...

include('Database.php'); //or Database_PDO.php

//Maybe just create Database object here and keep passwords in one place?
$DB = new Database($user,$pass);

//other config vars....


//Do stuff...

If you really need to have both available in one app, just add
arguments to your function (if needed) so you can pass them to the
constructors.  Of course at that point you might as well just have two
different named classes and use one or the other, the function is just
unnecessary and complicates things...

class Database {}
class PDODatabase{}

$dbA = new Database();
$dbB = new PDODatabase();

On Sun, May 24, 2009 at 1:10 AM, kranthi <kranthi...@gmail.com> wrote:
> thanks for the comments,
> what i m planning to do is....
> function _autoload($class) {
>  if($class == 'Database') {
>   if(class_exis('PDO') {
>    include_once('Database_PDO.php');
>   } else {
>    include_once('Database.php');
>  }
> }
> where in  Database_PDO.php contains
> class Database extends PDO {
> }
> Database.php contains
> class Database {
> }

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to