Red bean php R :: getAll不返回任何记录

时间:2013-01-26 09:27:15

标签: php mysql redbean

这是用红豆php生成的数据库结构:

CREATE TABLE `attrib` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `type` tinyint(3) unsigned DEFAULT NULL,
  `value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10 ;

CREATE TABLE `attrib_photo` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `attrib_id` int(11) unsigned DEFAULT NULL,
  `photo_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UQ_e472845bf988796e2d3eceb91e2745b95f3aa534` (`attrib_id`,`photo_id`),
  KEY `index_for_attrib_photo_attrib_id` (`attrib_id`),
  KEY `index_for_attrib_photo_photo_id` (`photo_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=19 ;


CREATE TABLE `photo` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `filepath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `date` set('1') COLLATE utf8_unicode_ci DEFAULT NULL,
  `iscolored` tinyint(3) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;


ALTER TABLE `attrib_photo`
  ADD CONSTRAINT `attrib_photo_ibfk_1` FOREIGN KEY (`attrib_id`) REFERENCES `attrib` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `attrib_photo_ibfk_2` FOREIGN KEY (`photo_id`) REFERENCES `photo` (`id`) ON DELETE CASCADE;

我正在制作手动构建的查询:

    output of R::debug(); R::getAll($sql);
        select filepath 
        from photo 
        inner join attrib as attrib4 on attrib4.type = 4 and attrib4.value in ("Dmitry") 
        inner join attrib_photo as attrib_photo4 on attrib_photo4.attrib_id = attrib4.id and attrib_photo4.photo_id = photo.id WHERE 1=1 LIMIT 0,25

Array ( ) 
 resultset: 0 rows
 []

结果集为空,但是基数包含符合要求的记录,并且在phpMyAdmin中手动运行sql会显示它们。

查询有什么问题,我可以处理任何其他调试信息来解决问题吗?感谢。

更新 缺少一些细节,在原始查询中我使用unicode字符串进行照片属性搜索。经过一些调查后,我发现php代码工作正常,而mysql端发生了错误的编码转换。决定是将整个数据库的整理更改为utf8_unicode_ci。感谢您的关注,并对有问题的遗失信息感到抱歉。

0 个答案:

没有答案