我试着将 INDEX FOR JOIN (PRIMARY
),还没有找到明确的答案,是否在ZF1中实现了,所以决定在这里问一下。是否实现了这一点,你能给出使用实例吗?https:/github.comzendframeworkzf1issues489。
我试着用这样的方法。
$this->db->select()->forceIndex('PRIMARY')->from('somefield')->..
但却返回一个错误。
Unrecognized method 'forceIndex()'
我不知道是我用错了还是根本没有实现。
你可以使用join()和where()函数来完成这种任务。
$select = $this->select()->from(array('c' => 'cities'),array('*'));
$select->distinct();
$select->join(array('l' => 'cities_lang'), 'c.id=l.city_id', array());
$select->where('l.locale_code = ?', $locale);
$select->where('l.city_name LIKE ?', $like);
$select->order('(l.city_name = ' . $db->quote($query) . ') DESC');
$select->limit($perpage, ($page-1)*$perpage);
$this->fetchAll($select);