2013-06-19 71 views
0

嗨似乎bindParam或bindValue方法都不起作用。bindParam或binValue將不起作用

請指教。我試圖將$ dbname綁定到dbtest。它似乎不工作!

bindParam

$dbname = "test1"; 
$stmt=$dbh->prepare('use :dbtest'); 
$stmt->bindParam(':dbtest', $dbname, PDO::PARAM_STR); 
$firephp->fb($stmt); 
try 
{ $stmt->execute(); 
    $stmt=$dbh->prepare('select database()'); 
    $stmt->execute(); 
    $count = $stmt->fetch(PDO::FETCH_ASSOC); 
    $firephp->warn("Attempting to use selected database is successful."); 
}  

bindValue

$dbname = "test1"; 
$stmt=$dbh->prepare('use :dbtest'); 
$stmt->bindValue(':dbtest', $dbname, PDO::PARAM_STR); 
$firephp->fb($stmt); 
try 
{ $stmt->execute(); 
    $stmt=$dbh->prepare('select database()'); 
    $stmt->execute(); 
    $count = $stmt->fetch(PDO::FETCH_ASSOC); 
    $firephp->warn("Attempting to use selected database is successful."); 
    $firephp->fb($count); 
}  

可能是什麼問題呢?

回答