我有一个问题,这是我的控制器的一部分,它为我提供了一个空数组:
$tifos = $model-> select()->setIntegrityCheck(false)
-> from(array('t'=>'tifos'), array('*', 'date'=>'DATE(t.created_at)'))
-> join(array('u'=>'users'), 'u.id=t.users_id', array('username', 'avatar'))
-> where('status = ?', $status)
-> order('likes DESC')
-> limit(10, 0)->query()->fetchAll()
;
$model 是扩展 Zend_Db_Table 的类的一个实例。
什么可能导致问题?我正在使用 Zend 1.12。
编辑
好的,这就是我现在得到的,我的 MySQL 查询:
SELECT `t`.*, DATE(`t`.`created_at`) AS `date`, `u`.`username`, `u`.`avatar` FROM `tifos` AS `t` INNER JOIN `users` AS `u` ON `u`.`id`=`t`.`users_id` WHERE (`t`.`status` = 'ok') ORDER BY `t`.`likes` DESC LIMIT 10
我的数据库结构:
CREATE TABLE IF NOT EXISTS `tifos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`users_id` int(11) NOT NULL,
`status` enum('ok','waiting','deleted') NOT NULL DEFAULT 'waiting',
`file` varchar(127) NOT NULL,
`description` varchar(255) NOT NULL,
`likes` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `users_id` (`users_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(63) NOT NULL,
`password` varchar(40) NOT NULL,
`email` varchar(63) NOT NULL,
`firstname` varchar(63) NOT NULL,
`lastname` varchar(63) NOT NULL,
`avatar` varchar(64) NOT NULL,
`email_verified` tinyint(1) NOT NULL,
`is_active` tinyint(1) NOT NULL,
`verification_key` varchar(40) NOT NULL,
`newsletter` tinyint(1) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;