-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for
SQL_CALC_FOUND_ROWS
Support added for mysql SQL_CALC_FOUND_ROWS, and easy pagination.
- Loading branch information
Showing
3 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* @author 10 Quality <[email protected]> | ||
* @license MIT | ||
* @package wp-query-builder | ||
* @version 1.0.3 | ||
* @version 1.0.6 | ||
*/ | ||
class QueryBuilderStatementsTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
@@ -674,4 +674,52 @@ public function testJoinRawStatement() | |
$wpdb->get_query() | ||
); | ||
} | ||
/** | ||
* Test query builder | ||
* @since 1.0.6 | ||
*/ | ||
public function testSelectCalcRowsStatement() | ||
{ | ||
// Preapre | ||
global $wpdb; | ||
$builder = QueryBuilder::create( 'test' ); | ||
// Prepare | ||
$builder->select( 'test_field' )->get( OBJECT, null, true ); | ||
// Assert | ||
$this->assertEquals( | ||
'SELECT SQL_CALC_FOUND_ROWS test_field FROM ', | ||
$wpdb->get_query() | ||
); | ||
} | ||
/** | ||
* Test query builder | ||
* @since 1.0.6 | ||
*/ | ||
public function testColCalcRowsStatement() | ||
{ | ||
// Preapre | ||
global $wpdb; | ||
$builder = QueryBuilder::create( 'test' ); | ||
// Prepare | ||
$builder->select( 'test_field' )->col( 0, true ); | ||
// Assert | ||
$this->assertEquals( | ||
'SELECT SQL_CALC_FOUND_ROWS test_field FROM ', | ||
$wpdb->get_query() | ||
); | ||
} | ||
/** | ||
* Test query builder | ||
* @since 1.0.6 | ||
*/ | ||
public function testRowsFoundStatement() | ||
{ | ||
// Preapre | ||
global $wpdb; | ||
$builder = QueryBuilder::create( 'test' ); | ||
// Prepare | ||
$builder->select( 'test_field' )->rows_found(); | ||
// Assert | ||
$this->assertEquals('SELECT FOUND_ROWS()', $wpdb->get_query()); | ||
} | ||
} |