-1

我想使用 PHP 从 MySQL 数据库中获取最后创建的表名。

我也使用了查询,但我无法获得任何价值。这是查询:

"select table_name from information_schema.tables where table_schema = 'databse_name' order by create_time desc limit 1"

当我使用它时,我从本地系统获得价值,但没有从客户的数据库中获得价值。我的查询中有什么错误?

4

2 回答 2

1

如果我理解正确,您的查询在本地计算机上运行良好,但在实时环境中却不行?

可能是直播环境中的MySQL用户权限不足?尝试在实时环境 MySQL 数据库中执行类似的操作:

GRANT SELECT ON information_schema.tables TO `user`@`localhost`

并替换user为正确的用户名,localhost如果您连接到本地主机之外的数据库,也可能是该部分。

于 2012-01-13T11:00:12.443 回答
0

您对要访问的数据库有权限吗?

请试试这个:

select create_time, table_name, table_schema 
from information_schema.tables 
where table_schema not in ('mysql')
and table_schema not like '%_schema'  
order by create_time desc 

你有没有得到结果,如果你没有得到你所指的数据库的结果,那么它必须是权限。

于 2012-01-13T11:07:35.527 回答