简体   繁体   English

使用Zend_Db_Table_Select编写子查询

[英]writing a subquery using Zend_Db_Table_Select

I am not able to convert the below query into Zend_Db_Table_Select query. 我无法将以下查询转换为Zend_Db_Table_Select查询。

SELECT GROUP_CONCAT(wallet_transaction_id) as wallet_transaction_ids,transaction_type,source,status
FROM(
    SELECT wallet_transaction_id, transaction_type, source, status
    FROM ubiw_transactions_wallet
    WHERE (game_id = '1292') AND (player_id = 1538) 
    ORDER BY date DESC LIMIT 100
) a 
GROUP BY a.transaction_type,a.status, a.transaction_type;

any help is appreciated. 任何帮助表示赞赏。

thanks, shiv 谢谢,谢谢

// Maybe need some changes

$table = new Zend_Db_Table('ubiw_transactions_wallet');

$subSelect = $table->select()
->from('ubiw_transactions_wallet', array('wallet_transaction_id', 'transaction_type', 'source', 'status'))
->where($table->getAdapter()->quoteInto('game_id = ?', 1292))
->where($table->getAdapter()->quoteInto('player_id = ?', 1538))
->order('`date` DESC')
->limit(100);

$mainSelect = $table->select()
->setIntegrityCheck(false)
->from(array('a' => $subSelect), array('wallet_transaction_ids' => new Zend_Db_Expr('GROUP_CONCAT(wallet_transaction_id)'), 'transaction_type', 'source', 'status'))
->group(array('a.transaction_type', 'a.status', 'a.transaction_type'));

$result = $table->fetchAll($select);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM