NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP 5 Baffles Me

Joseph Crawford codebowl at gmail.com
Mon Aug 8 15:37:28 EDT 2005


Hey Guys,

i am working on a database class however i am not getting the expected 
results.

<?php
using("System.Database.Drivers");
class Database {

public function __construct($dsn = 'mysql://csaf:bose343@localhost/csaf', 
$persistant = false) {
$d = explode(':', $dsn);
$driver = ucfirst(strtolower($d[0]));
if(isset($driver)) {
if(isset($dsn)) return new $driver($dsn, $persistant);
else throw new DatabaseEx('Invalid DSN'); 
}
else throw new DatabaseEx('Invalid Driver!');
}
}

$dsn = "mysql://user:pass@localhost/csaf";
$db = new Database($dsn);
$db->Open();
$res = $db->Query("SELECT username FROM admins WHERE id=1");
$data = $db->FetchArray($res);
$db->Close();
print_r($data);
?>

i get the follwing error with that code.

*Fatal error*: Call to undefined method Database::Open() in *
E:\htdocs\csaf1\global.php* on line *156*

if i do 
if($db instanceof Mysql) echo "YAY"; 
it never echo's but if i change Mysql to Database it will echo.
Any help / explanation would be appreciated.

-- 
Joseph Crawford Jr.
Codebowl Solutions, Inc.
1-802-671-2021
codebowl at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20050808/5f8f9134/attachment.html>


More information about the talk mailing list