PHP获取pdo,列名称中带有连字符
所以我在写一个php项目,我被数据库中表的列名中的连字符卡住了。 我有以下代码:PHP获取pdo,列名称中带有连字符,php,mysql,sql,database,pdo,Php,Mysql,Sql,Database,Pdo,所以我在写一个php项目,我被数据库中表的列名中的连字符卡住了。 我有以下代码: $results = $conn->query($sql)->fetchAll(PDO::FETCH_OBJ); foreach ($results as $row) { ?> <tr> <td><a href="#<?= $row->factuur-status ?>"><?= $row->
$results = $conn->query($sql)->fetchAll(PDO::FETCH_OBJ);
foreach ($results as $row) { ?>
<tr>
<td><a href="#<?= $row->factuur-status ?>"><?= $row->factuur-status ?></a></td>
<td><?= $row->verkoop-orderid ?></td>
</tr>
<?php } ?>
$results=$conn->query($sql)->fetchAll(PDO::FETCH_OBJ);
foreach($results作为$row){?>
现在很明显,由于列名中的连字符,这不起作用。
如何解决这个问题?我找到了,如果有人感兴趣:
<?= $row->{'factuur-status'} ?>
use`to escape the hyphen column names我无法在我编写的代码中使用这些(``)。我已经尝试过了。。。