关联表OR查询出错
两个表,一个是文章,另一个是文章评论现在通过评论表中搜索文章标题或id符合条件的记录。
我写的条件如下:
$conditions = array(
array('article_id',"%{$_REQUEST['byarticle']}%",'LIKE','OR'),
array('articles.title1',"%{$_REQUEST['byarticle']}%",'LIKE')
);
fleaf运行进提示错误,语句中的OR被替换为AND,并且缺少了一个单引号。
提示信息如下:
SQL 错误消息: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%DFGD%'' at line 1" SQL 语句: "SELECT DISTINCT COUNT(`mcp_comments`.`comment_id`) FROM `mcp_comments` LEFT JOIN `mcp_articles` ON `mcp_articles`.`article_id` = `mcp_comments`.`article_id` WHERE `mcp_comments`.`article_id` LIKE '1 AND `mcp_articles`.`title1` LIKE '%DFGD%'" SQL 错误代码: "7335941".错误原因:您看到这个错误页面是因为应用程序抛出了没有捕获的异常。
[b]异常的详细内容:[/b] exception 'FLEA_Db_Exception_SqlQuery' with message 'SQL 错误消息: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%DFGD%'' at line 1"
SQL 语句: "SELECT DISTINCT COUNT(`mcp_comments`.`comment_id`) FROM `mcp_comments` LEFT JOIN `mcp_articles` ON `mcp_articles`.`article_id` = `mcp_comments`.`article_id` WHERE `mcp_comments`.`article_id` LIKE '1 AND `mcp_articles`.`title1` LIKE '%DFGD%'"
SQL 错误代码: "7335941".' in /home/webroot/mcplive/html/libs/FLEA/FLEA/Db/Driver/Mysql.php:126
Stack trace:
#0 /home/webroot/mcplive/html/libs/FLEA/FLEA/Db/Driver/Abstract.php(562): FLEA_Db_Driver_Mysql->execute('SELECT DISTINCT...')
#1 /home/webroot/mcplive/html/libs/FLEA/FLEA/Db/TableDataGateway.php(731): FLEA_Db_Driver_Abstract->getOne('SELECT DISTINCT...')
#2 /home/webroot/mcplive/html/libs/FLEA/FLEA/Helper/Pager.php(208): FLEA_Db_TableDataGateway->findCount(Array)
#3 /home/webroot/mcplive/html/admin/app/Controller/CommentMa.php(36): FLEA_Helper_Pager->FLEA_Helper_Pager(Object(Model_Comment), 0, 2, Array, 'created DESC', 1)
#4 /home/webroot/mcplive/html/libs/FLEA/FLEA/Dispatcher/Simple.php(120): Controller_CommentMa->actionIndex()
#5 /home/webroot/mcplive/html/libs/FLEA/FLEA/Dispatcher/Simple.php(77): FLEA_Dispatcher_Simple->_executeAction('CommentMa', 'index', 'Controller_Comm...')
#6 /home/webroot/mcplive/html/libs/FLEA/FLEA.php(816): FLEA_Dispatcher_Simple->dispatching()
#7 /home/webroot/mcplive/html/admin/index.php(29): FLEA::runMVC()
#8 {main}
[b]Exception: [/b]FLEA_Db_Exception_SqlQuery
[b]Message: [/b]SQL 错误消息: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%DFGD%'' at line 1" SQL 语句: "SELECT DISTINCT COUNT(`mcp_comments`.`comment_id`) FROM `mcp_comments` LEFT JOIN `mcp_articles` ON `mcp_articles`.`article_id` = `mcp_comments`.`article_id` WHERE `mcp_comments`.`article_id` LIKE '1 AND `mcp_articles`.`title1` LIKE '%DFGD%'" SQL 错误代码: "7335941". 你试试看下载最新的 fleaphp,这个问题应该已经修正了 哈哈~ 楼主在开发MC的新网站?
mcplive.com.cn
强!
页:
[1]