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