是否可以通过 php 中的 PDO OCI 查询获取列格式?
在 PHP5 中, 我有一个 Oracle 查询..假设
select month,max(mydate) as maxdate,sum(cash) as total_cash from mytable group by month
我想通过 PDO OCI 根据每列的类型来格式化表
Month=varchar 最大日期=日期 Total_cash=number
有没有办法从Oracle获取列类型?由于我的查询可以更改,我无法在 Oracle 系统表中查找类型:列可以是计算或列的串联
谢谢
in php5,
i have an oracle query .. let's say
select month,max(mydate) as maxdate,sum(cash) as total_cash from mytable group by month
i would like, through PDO OCI, to format a table according to the type of each column
month=varchar
maxdate=date
total_cash=number
is there a way to obtain the column types from Oracle ? as my query can be changed, i can't look in oracle system table to get the type : columns can be calculations or concatenations of columns
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 PDO 中执行此操作的官方方法是调用
PDOStatement::getColumnMeta( )
执行查询后。结果集中的每列调用一次,其中零列是第一个。不过,它需要驱动程序支持,而且我不能保证 Oracle 驱动程序。
The official way to do this in PDO is calling
PDOStatement::getColumnMeta()
after performing a query. Call it once per column in the result set, where column zero is the first.It requires driver support, though, and I can't vouch for the Oracle driver.
在 Oracle 中,有一些系统视图允许您查询此信息。
In Oracle, there are system views that will allow you to query for this information.
如果您在 Oracle 数据库中拥有有限的权限,您仍然可以通过查询来查找数据类型
。该视图中有更多感兴趣的列,例如 last_analyzed 和用作优化器输入的其他值。
If you have limited privileges in an Oracle database you can still find the datatypes by querying
There are more columns of interest in that view, for example last_analyzed and other values used as input for the optimizer.