mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 04:26:20 +00:00
Disabling ORDER BY clause for Model::findCount (Ticket #2227) and updating test case
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4677 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7737224368
commit
f48b908ac6
3 changed files with 20 additions and 10 deletions
|
@ -1386,7 +1386,7 @@ class Model extends Overloadable {
|
||||||
$offset = ($page - 1) * $limit;
|
$offset = ($page - 1) * $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($order == null) {
|
if ($order == null && $order !== false) {
|
||||||
if ($this->order == null) {
|
if ($this->order == null) {
|
||||||
$order = array();
|
$order = array();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1495,7 +1495,7 @@ class Model extends Overloadable {
|
||||||
* @see Model::findAll
|
* @see Model::findAll
|
||||||
*/
|
*/
|
||||||
function findCount($conditions = null, $recursive = 0) {
|
function findCount($conditions = null, $recursive = 0) {
|
||||||
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', $this->escapeField(), null, 1, $recursive);
|
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', false, null, 1, $recursive);
|
||||||
|
|
||||||
if (isset($data[0]['count'])) {
|
if (isset($data[0]['count'])) {
|
||||||
return $data[0]['count'];
|
return $data[0]['count'];
|
||||||
|
|
|
@ -768,7 +768,6 @@ class Router extends Object {
|
||||||
*/
|
*/
|
||||||
if(!function_exists('http_build_query')) {
|
if(!function_exists('http_build_query')) {
|
||||||
function http_build_query($data, $prefix = null, $argSep = null, $baseKey = null) {
|
function http_build_query($data, $prefix = null, $argSep = null, $baseKey = null) {
|
||||||
//die('?');
|
|
||||||
if(empty($argSep)) {
|
if(empty($argSep)) {
|
||||||
$argSep = ini_get('arg_separator.output');
|
$argSep = ini_get('arg_separator.output');
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,14 +383,25 @@ class ModelTest extends CakeTestCase {
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
/*
|
|
||||||
$result = $this->model->hasMany;
|
|
||||||
$expected = array();
|
|
||||||
$this->assertEqual($result, $expected);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testFindCount() {
|
||||||
|
$this->model =& new User();
|
||||||
|
$result = $this->model->findCount();
|
||||||
|
$this->assertEqual($result, 4);
|
||||||
|
|
||||||
|
$this->db->fullDebug = true;
|
||||||
|
$this->model->order = 'User.id';
|
||||||
|
$result = $this->model->findCount();
|
||||||
|
$this->assertEqual($result, 4);
|
||||||
|
|
||||||
|
$this->assertTrue(isset($this->db->_queriesLog[0]['query']));
|
||||||
|
$this->assertNoPattern('/ORDER\s+BY/', $this->db->_queriesLog[0]['query']);
|
||||||
|
|
||||||
|
$this->db->_queriesLog = array();
|
||||||
|
$this->db->fullDebug = false;
|
||||||
|
}
|
||||||
|
|
||||||
function testFindMagic() {
|
function testFindMagic() {
|
||||||
$this->model =& new User();
|
$this->model =& new User();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue