I have a DB extraction class I wrote that supports both MySQL and MSSQL (and
can be easily extended to support others).
My class is also called DB.
<?
define( "MSSQL_DB", 1);
define( "MYSQL_DB",2);
class DB
{
var $db_type;
function DB($type)
{
$this->db_type = $type; ## the type of database connecting to: mssql or
mysql.
}
function connect($host,$un,$pw)
{ ##....
return $link
}
function select_db($dbname)
{
##....
return $dblink;
}
## ...
} // end class DB
?>
To instantiate a class, you have to use "new"
$db = new DB(MSSQL_DB); #
$link = $db->connect($host,$un,$pw);
$dblink = $db->select_db($dbname);
The syntax below:
> $conn = DB::Connect($connstr);
> $conn->query($sql);
Is that it? Because maybe that is a form of using the class statically (??
reminds me of Java).
"Brian Feliciano" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> i've seen a code like this...
> -----------
> $conn = DB::Connect($connstr);
> $conn->query($sql);
> -----------
> i think this is from PEAR's DB abstraction layer..
> but my problem is, i don't know how to create a class
> like the 'DB'. I tried to, but i failed.
>
> How can i create an instance of a class without using
> "new" ?
>
>
>
>
>
>
> --
> =============================
> B r i a n F e l i c i a n o
> =============================
> Server Administrator
> The Websense Group Co.
> -----------------------------
> Unit 103 Terris Villa Sikap St.
> Mandaluyong City, Philippines
> Tel. No.: (632) 7462449
> Fax. No.: (632) 7462482
> Mobile Phone No.: +639176189153
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php