10.4. Zend_db_select
You can use this object and its corresponding method to build a SELECT query statement, and then generate a string character to be passed to Zend_db_adapter for query or read results.
You can also use a bound argument in your query statement without having to add a reference to the parameter.
10.4.2. Querying multiple columns of data in the same table
10.4.3. Multi-Table union query
10.4.4. Where Condition
10.4.5. GROUP BY clause
10.4.6. Having conditions
10.4.7. ORDER BY clause
10.4.8. Limit restrictions by total and offset
Zend_db_select can support the limit statement limits of the database tier. For some databases, such as MySQL and PostgreSQL. Implementing these is relatively easy, as these databases natively support the "limit:count" syntax.
For some other databases. Microsoft's SQL Server and Oracle, for example, are less simple to implement the limit function because they do not support the limit statement at all.
Ms-sql has a top statement to implement, and for Oracle to implement the limit function, the query statement is more specific.
Due to the way Zend_db_select works internally. We are able to rewrite the SELECT statement to implement the limit functionality of the above open source database system in Oracle.
To limit the returned results by setting the total number and offset of the query, you can use the limit () method, the total value, and an optional offset as the number of parameters to invoke the method.
<?Php///First, a simple "limit:count"$select = $db -Select();$select -From' foo ',' * ');$select -Order(' id ');$select -LimitTen);////In Mysql/psotgresql/sqlite, this statement can be obtained:////SELECT * from Foo//ORDER by ID ASC//LIMIT////But under Microsoft SQL, you can get this statement:////SELECT TOP ten * from FOO//ORDER by ID ASC//////Today is a more complex "limit:count offset:offset" approach$select = $db -Select();$select -From' foo ',' * ');$select -Order(' id ');$select -LimitTen, -);////In Mysql/psotgresql/sqlite, this statement can be obtained:////SELECT * from Foo//ORDER by ID ASC//LIMIT OFFSET////However, under Microsoft SQL, this SQL statement can be obtained because the offset feature is not supported:////SELECT * FROM (//SELECT TOP ten * FROM (//SELECT TOP * from foo ORDER by ID DESC// ) ORDER by ID ASC// )////Zend_db_adapter be able to complete the dynamic creation of SQL statements on its own initiative.//?
>
10.4.9. Limit restrictions by number of pages and totals
3.2 Zend_db_select