2
我创建2类并从1类我引用其他类PDO对象。但是,当我引用该类的任何字符串时,而不是在PDO对象时。有任何想法吗? 这是我的代码PHP类引用PDO对象
class Connection
{
private $dbcc;
public function Fn_Db_Conn()
{
$this->dbcc = new PDO("mysql:host=localhost;dbname=db1;",
"root","pass1");
return $this->dbcc;
}
}
class Registration
{
private $Username;
private $dbc;
public function Registration($Un)
{
$this->Username = $Un;
$this->dbc = new Connection;
$this->dbc->Fn_Db_Conn();
}
public function Fn_User_Exist()
{
$Qry = "SELECT * FROM CMT_Users WHERE [email protected]";
$Result = $this->dbc->prepare($Qry);
$Result->bindParam("@Username",$this->Username);
$Result->execute();
print $Result->rowCount();
}
}
谢谢,它已经解决了,再次感谢那些建议。 – DON 2011-12-26 15:53:29