2009年1月9日星期五

[fw-core] Zend_DB_Select, fully re-build columns?

Hi guys, using latest svn copy of ZF, i got trouble.

<?php

// ... require other code goes here ...

$profession_rewrite = 'dodo';

$select = $db->select();
$select->from('finders');
$select->joinLeftUsing('finder_images', 'finder_id');
$select->joinLeftUsing('professions', 'profession_id');
$select->where('finder_moderated = ?', 1);
$select->where('profession_rewrite = ?', $profession_rewrite);
$select->order('finder_image_path_preview DESC');
$select->order('finder_created_at DESC');
$select->limitPage($page, $per_page);

print $select;

?>

will return to me:

SELECT `finders`.*, `finder_images`.*, `professions`.* FROM `finders` LEFT JOIN `finder_images` ON `finder_images`.finder_id = `finders`.finder_id LEFT JOIN `professions` ON `professions`.profession_id = `finders`.profession_id WHERE (finder_moderated = 1) AND (profession_rewrite = 'other') ORDER BY `finder_image_path_preview` DESC, `finder_created_at` DESC LIMIT 20

how i can re-build it, into:

SELECT * ...

because, joined `finder_images` table rewrites `finder_id` of `finders` table.

没有评论: