我似乎无法找到为什么会出现意外的 T_variable 错误。我试图使用一个类来调用我的数据库。错误在第 18 行
$query = $this->link->query("SELECT * FROM markers WHERE 1");
这是我的整个班级。
有什么线索吗?
class Users{
private $link;
public function __construct(){
$this->link = new Connection();
$this->link = $this->link->dbConnect();
}
$query = $this->link->query("SELECT * FROM markers WHERE 1");
$query->$this->link->setFetchMode(PDO::FETCH_ASSOC);
header("Content-type: text/xml");
while($row = $stmt->fetch()) {
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("adress", $row['adress']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("type", $row['type']);
}
echo $dom->saveXML();
}
第 18 和 19 行是
$query = $this->link->query("SELECT * FROM markers WHERE 1");
$query->$this->link->setFetchMode(PDO::FETCH_ASSOC);