douque2016 2015-09-24 04:11
浏览 52

检索当前数据库表名并使用PHP存储到变量中

I am looking on how to retrieve a table name that is currently active so that I can store that table name into a variable and then use it in a query that will need to fetch the tablename the data is located in. I have looked on Stack and Google and cannot find a simple solution to this. I wish I could provide an example of what I am already working with but the truth is that I have not found anything of use that will help me do this simple task.

I want to select table name and store, that is all. Sounds simple enough, I hope I don't get down votes for this one but I really need to find an answer to this even if points are lost.

To clarify: I want to find a way to use the same script for different table names. We have different categories of tables. I would like the query to search certain columns on a specific tables based on the current table that is being accessed. We have table 1 and table 2 with the some columns that are the same name but only table 1 is being accessed at the moment. If administrators want to make a change to image in a table it needs to be done in the table that is currently accessed so that I do not duplicate my code just to accommodate different table names.

  • 写回答

2条回答 默认 最新

  • dongpao1918 2015-09-24 04:21
    关注

    Sounds not simple.

    Probably you have some "problems" with understanding how to work with database.

    You (your app-code) should always know names of all database tables it wants to use.

    Just know. Not fetching them.

    Fetching them have no sense.

    To write queries in your app-code you should know not only then tables names but all their fields, their types, in other words structure.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法