PHP PDO MSSQL准备我在使用基于功能的PDO麻烦声明
我GetCurrentLanguage()
函数返回0 int或1
public function GetCurrentLangName()
{
$stmt = $GLOBALS['website']->prepare("SELECT * FROM available_languages WHERE id = :id");
$stmt->bindParam(':id', $this->GetCurrentLanguage(), PDO::PARAM_INT);
$stmt->execute();
$fetch = $stmt->fetchAll();
return $fetch['name'];
}
,并不能正常工作,它返回
注意:未定义指数:命名
你可以[检查手册](http://php.net/manual/en/pdostatement.fetchall.php)或'var_dump($ fetch)'看看会发生什么......在你的情况下,'fetchAll'将所有rowS作为数组返回,所以它是一个数组数组。您可能需要使用'$ fetch [0] ['name']'(如果您确定至少会返回一行)。 – Passerby 2014-10-05 02:49:28