dotcraq3249 2012-07-25 06:32
浏览 50

如何使用索引为多个数据库创建搜索引擎[重复]

Possible Duplicate:
How do you connect to multiple MySQL databases on a single webpage?

I am building a search engine for my website, I have 6 databases with many tables.

For multiple database I know I have to build a index file containing information from all database and tables.

I know how to build a search engine for database in PHP and MySQL,

Connect to multiple database

mysql_connect(“hostname”, “username”, “password”);
mysql_select_db(“database1”);

mysql_connect(“hostname”, “username”, “password”);
mysql_select_db(“database2”);

and query like this

"(SELECT * from database1.search_table WHERE MATCH (title, link) AGAINST(‘keyword’))
  Union All 
 (SELECT * from database2.search_table WHERE MATCH (title, link) AGAINST(‘keyword’)"

I want to do it by making an index file.

Please suggest any good tutorial or method for this, I google many times but no good results.

  • 写回答

1条回答 默认 最新

  • dongnaota6386 2012-07-25 06:51
    关注

    I think of three ways to do this: 1-st You can user multiple database connection. That's the heaviest way to do this, because it'll increase the connections to the server. 2-nd You can just switch the chosen database. 3-rd You can make your queries database independent by selecting the database in the query. Here's an example :

    SELECT * FROM `database`.`table` WHERE `database`.`table`.`column`='something'
    

    I personally think that the third way is the best.

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题