【问题标题】:PHP: convert mysql code so it will work with innodb?PHP:转换 mysql 代码以便它可以与 innodb 一起使用?
【发布时间】:2012-07-10 14:47:00
【问题描述】:

我已从 myisam 迁移到 innodb,我不得不从表中删除全文索引。 现在我的脚本的某些部分不起作用,我如何转换下面的代码以便它可以与 innodb 一起使用?

$posts_fields = "SELECT SQL_CALC_FOUND_ROWS id, autor, " . PREFIX . "_post.date AS newsdate, " . PREFIX ."_post.date AS date, short_story AS story, " . PREFIX . "_post.xfields AS xfields, title, descr, keywords, category, alt_name,comm_num AS comm_in_news, allow_comm, rating, news_read, flag, editdate, editor, reason, view_edit, tags, '' AS output_comms";
$posts_from = "FROM " . PREFIX . "_post";
$sql_find = "$sql_fields $posts_from $where";

【问题讨论】:

  • 什么不再起作用了?问题很可能出在$where 中,如果您使用例如“MATCH(..) AGAINST(..)”,则未提供。
  • MySQL 5.6 支持 InnoDB 表上的 FULLTEXT 索引:dev.mysql.com/tech-resources/articles/…。话虽如此,您的 PHP 毫无用处 - 向我们展示生成的查询字符串是什么样的。
  • 该代码所做的只是从表中选择一个字段列表。没有代码会依赖于存储引擎,也没有代码依赖于索引、FULLTEXT 或其他。请显示您在尝试运行查询时收到的错误消息。
  • 这是我得到MySQL Error! ------------------------ The Error returned was: The used table type doesn't support FULLTEXT indexes Error Number: 1214 SELECT SQL_CALC_FOUND_ROWS id, autor, dle_post.date AS newsdate, dle_post.date AS date, short_story AS story, dle_post.xfields AS xfields, title, descr, keywords, category, alt_name,comm_num AS comm_in_news, allow_comm, rating, news_read, flag, editdate, editor, reason, view_edit, tags, '' AS output_comms FROM dle_post WHERE dle_post.approve=1 AND MATCH(title,short_story,full_story,dle_post.xfields) AGAINST ('test' LIMIT 0,36的错误
  • 升级到 5.6 解决了我的问题

标签: php mysql innodb myisam full-text-indexing


【解决方案1】:
$posts_fields = "SELECT SQL_CALC_FOUND_ROWS id, autor, " . PREFIX . "_post.date AS newsdate, " . PREFIX ."_post.date AS date, short_story AS story, " . PREFIX . "_post.xfields AS xfields, title, descr, keywords, category, alt_name,comm_num AS comm_in_news, allow_comm, rating, news_read, flag, editdate, editor, reason, view_edit, tags, '' AS output_comms";
$posts_from = "FROM " . PREFIX . "_post";
$sql_find = "$sql_fields $posts_from $where";

应该改为

$posts_fields = "SELECT SQL_CALC_FOUND_ROWS id, autor, " . PREFIX . "_post.date AS newsdate, " . PREFIX ."_post.date AS date, short_story AS story, " . PREFIX . "_post.xfields AS xfields, title, descr, keywords, category, alt_name,comm_num AS comm_in_news, allow_comm, rating, news_read, flag, editdate, editor, reason, view_edit, tags, '' AS output_comms";
$posts_from = "FROM " . PREFIX . "_post";
$sql_find = "$post_fields $posts_from $where";

还要仔细检查你的 where 条件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-12
    • 2011-12-24
    • 1970-01-01
    • 2016-11-24
    • 2016-05-28
    • 1970-01-01
    相关资源
    最近更新 更多