我有带有“ operation.date”,“ operation.name”等列的mysql表。用我获取该表数据作为对象后,$mysqli->fetch_object()得到此信息(行的print_r):
$mysqli->fetch_object()
stdClass Object ( [id] => 2 [operation.date] => 2010-12-15 [operation.name] => some_name )
我怎么存取权限operation.date,并operation.name和所有其他古怪的命名对象的属性?
operation.date
operation.name
在您的SQL查询中指定别名,例如SELECT column AS nameWithoutDots ... 或访问这些属性,$object->{'operation.name'} 或将对象强制转换为数组,如下所示:$obj = (array)$obj; echo $obj['operation.name']。
SELECT column AS nameWithoutDots ...
$object->{'operation.name'}
$obj = (array)$obj; echo $obj['operation.name']