使用子查询将mysql查询转换为zf2

时间:2016-11-30 08:58:21

标签: mysql zend-framework2

我想将此mysql查询(SELECT * FROM (SELECT * FROM practice_details LIMIT 6 OFFSET 5) a ORDER BY practice_name ASC)转换为zend框架2,但不知道如何转换。我是新手。

谢谢你

1 个答案:

答案 0 :(得分:0)

2个步骤:

首先:写下子选择SELECT * FROM practice_details LIMIT 6 OFFSET 5

$subselect = new Select();
$subselect->from('practice_details')->limit(6)->offset(5);`

然后:写下选择

$select = new Select();
$select->from(['a' => $subselect])->order('practice_name ASC');