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:
nate 2007-03-25 18:17:15 +00:00
parent 7737224368
commit f48b908ac6
3 changed files with 20 additions and 10 deletions

View file

@ -1386,7 +1386,7 @@ class Model extends Overloadable {
$offset = ($page - 1) * $limit;
}
if ($order == null) {
if ($order == null && $order !== false) {
if ($this->order == null) {
$order = array();
} else {
@ -1495,7 +1495,7 @@ class Model extends Overloadable {
* @see Model::findAll
*/
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'])) {
return $data[0]['count'];

View file

@ -768,7 +768,6 @@ class Router extends Object {
*/
if(!function_exists('http_build_query')) {
function http_build_query($data, $prefix = null, $argSep = null, $baseKey = null) {
//die('?');
if(empty($argSep)) {
$argSep = ini_get('arg_separator.output');
}

View file

@ -383,14 +383,25 @@ class ModelTest extends CakeTestCase {
))
);
$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() {
$this->model =& new User();