这是选择:
.lispworks
我回来的数组看起来像这样:
select distinct YEAR(ovl_dat) from db;
这是将数组读入选项(joomla)
的代码Array (
[0] => stdClass Object ( [YEAR(ovl_dat)] => 1995 )
[1] => stdClass Object ( [YEAR(ovl_dat)] => 1957 )
[2] => stdClass Object ( [YEAR(ovl_dat)] => 1994 )
[3] => stdClass Object ( [YEAR(ovl_dat)] => 1982 )
[4] => stdClass Object ( [YEAR(ovl_dat)] => 1997 ) )
我在阅读$ enkeljaar->年(ovl_dat)时遇到问题。有人可以告诉我该怎么做吗?
关于Jan
答案 0 :(得分:1)
您应该为列名和
使用别名select distinct YEAR(ovl_dat) as my_year from db;
引用别名来获取值,例如假设你的结果是$ row
中的返回值$row['my_year'];
答案 1 :(得分:1)
使用任意名称获取/设置对象属性的语法是:
$foo = (object)null;
$foo->{'[YEAR(ovl_dat)]'} = 2018;
$foo->{'One
Two->Three'} = 'Hi';
var_dump($foo->{'[YEAR(ovl_dat)]'}, $foo->{'One
Two->Three'});
(demo)
但是,除非您参加代码混淆比赛,否则您可能想要指定一个正确的名称:
select distinct YEAR(ovl_dat) as distinct_year from db;