Changeset 3538
- Timestamp:
- 01/17/08 14:37:11 (18 months ago)
- Files:
-
- 3 modified
-
branches/0.10/lib/Doctrine/Pager.php (modified) (6 diffs)
-
branches/0.9/lib/Doctrine/Pager.php (modified) (6 diffs)
-
trunk/lib/Doctrine/Pager.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Pager.php
r3529 r3538 40 40 41 41 /** 42 * @var Doctrine_Query $_countQuery Doctrine_Query object related to the counter of pager 43 */ 44 protected $_countQuery; 45 46 /** 47 * @var array $_countQueryParams Hold the params to be used by Doctrine_Query counter object of pager 48 */ 49 protected $_countQueryParams; 50 51 /** 42 52 * @var integer $_numResults Number of results found 43 53 */ … … 97 107 { 98 108 // retrieve the number of items found 99 $count = $this->get Query()->count($params);109 $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 100 110 $this->_setNumResults($count); 101 111 … … 378 388 * getQuery 379 389 * 380 * Returns the Doctrine_Query object related to the pager381 * 382 * @return Doctrine_Query Doctrine_Query object related to the pager390 * Returns the Doctrine_Query collector object related to the pager 391 * 392 * @return Doctrine_Query Doctrine_Query object related to the pager 383 393 */ 384 394 public function getQuery() … … 391 401 * _setQuery 392 402 * 393 * Defines the maximum number of itens per page394 * 395 * @param $query Accepts either a Doctrine_Query object or a string396 * (which does the Doctrine_Query class creation).403 * Defines the collector query to be used by pager 404 * 405 * @param Doctrine_Query Accepts either a Doctrine_Query object or a string 406 * (which does the Doctrine_Query class creation). 397 407 * @return void 398 408 */ … … 404 414 405 415 $this->_query = $query; 416 } 417 418 419 /** 420 * getCountQuery 421 * 422 * Returns the Doctrine_Query object that is used to make the count results to pager 423 * 424 * @return Doctrine_Query Doctrine_Query object related to the pager 425 */ 426 public function getCountQuery() 427 { 428 return ($this->_countQuery !== null) ? $this->_countQuery : $this->_query; 429 } 430 431 432 /** 433 * setCountQuery 434 * 435 * Defines the counter query to be used by pager 436 * 437 * @param Doctrine_Query Accepts either a Doctrine_Query object or a string 438 * (which does the Doctrine_Query class creation). 439 * @return void 440 */ 441 public function setCountQuery($query) 442 { 443 if (is_string($query)) { 444 $query = Doctrine_Query::create()->parseQuery($query); 445 } 446 447 $this->_countQuery = $query; 448 449 $this->_setExecuted(false); 450 } 451 452 453 /** 454 * getCountQueryParams 455 * 456 * Returns the params to be used by counter Doctrine_Query 457 * 458 * @return array Doctrine_Query counter params 459 */ 460 public function getCountQueryParams($defaultParams = array()) 461 { 462 return ($this->_countQueryParams !== null) ? $this->_countQueryParams : $defaultParams; 463 } 464 465 466 /** 467 * setCountQueryParams 468 * 469 * Defines the params to be used by counter Doctrine_Query 470 * 471 * @param array Optional params to be used by counter Doctrine_Query. 472 * If not defined, the params passed to execute method will be used. 473 * @param boolean Optional argument that append the query param instead of overriding the existent ones. 474 * @return void 475 */ 476 public function setCountQueryParams($params = array(), $append = false) 477 { 478 if ($append && is_array($this->_countQueryParams)) { 479 $this->_countQueryParams = array_merge($this->_countQueryParams, $params); 480 } else { 481 $this->_countQueryParams = $params; 482 } 483 484 $this->_setExecuted(false); 406 485 } 407 486 … … 419 498 public function execute($params = array(), $hydrationMode = Doctrine::FETCH_RECORD) 420 499 { 421 $this->_initialize($params); 500 if (!$this->getExecuted()) { 501 $this->_initialize($params); 502 } 422 503 423 504 return $this->getQuery()->execute($params, $hydrationMode); -
branches/0.9/lib/Doctrine/Pager.php
r3529 r3538 40 40 41 41 /** 42 * @var Doctrine_Query $_countQuery Doctrine_Query object related to the counter of pager 43 */ 44 protected $_countQuery; 45 46 /** 47 * @var array $_countQueryParams Hold the params to be used by Doctrine_Query counter object of pager 48 */ 49 protected $_countQueryParams; 50 51 /** 42 52 * @var integer $_numResults Number of results found 43 53 */ … … 97 107 { 98 108 // retrieve the number of items found 99 $count = $this->get Query()->count($params);109 $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 100 110 $this->_setNumResults($count); 101 111 … … 378 388 * getQuery 379 389 * 380 * Returns the Doctrine_Query object related to the pager381 * 382 * @return Doctrine_Query Doctrine_Query object related to the pager390 * Returns the Doctrine_Query collector object related to the pager 391 * 392 * @return Doctrine_Query Doctrine_Query object related to the pager 383 393 */ 384 394 public function getQuery() … … 391 401 * _setQuery 392 402 * 393 * Defines the maximum number of itens per page394 * 395 * @param $query Accepts either a Doctrine_Query object or a string396 * (which does the Doctrine_Query class creation).403 * Defines the collector query to be used by pager 404 * 405 * @param Doctrine_Query Accepts either a Doctrine_Query object or a string 406 * (which does the Doctrine_Query class creation). 397 407 * @return void 398 408 */ … … 404 414 405 415 $this->_query = $query; 416 } 417 418 419 /** 420 * getCountQuery 421 * 422 * Returns the Doctrine_Query object that is used to make the count results to pager 423 * 424 * @return Doctrine_Query Doctrine_Query object related to the pager 425 */ 426 public function getCountQuery() 427 { 428 return ($this->_countQuery !== null) ? $this->_countQuery : $this->_query; 429 } 430 431 432 /** 433 * setCountQuery 434 * 435 * Defines the counter query to be used by pager 436 * 437 * @param Doctrine_Query Accepts either a Doctrine_Query object or a string 438 * (which does the Doctrine_Query class creation). 439 * @return void 440 */ 441 public function setCountQuery($query) 442 { 443 if (is_string($query)) { 444 $query = Doctrine_Query::create()->parseQuery($query); 445 } 446 447 $this->_countQuery = $query; 448 449 $this->_setExecuted(false); 450 } 451 452 453 /** 454 * getCountQueryParams 455 * 456 * Returns the params to be used by counter Doctrine_Query 457 * 458 * @return array Doctrine_Query counter params 459 */ 460 public function getCountQueryParams($defaultParams = array()) 461 { 462 return ($this->_countQueryParams !== null) ? $this->_countQueryParams : $defaultParams; 463 } 464 465 466 /** 467 * setCountQueryParams 468 * 469 * Defines the params to be used by counter Doctrine_Query 470 * 471 * @param array Optional params to be used by counter Doctrine_Query. 472 * If not defined, the params passed to execute method will be used. 473 * @param boolean Optional argument that append the query param instead of overriding the existent ones. 474 * @return void 475 */ 476 public function setCountQueryParams($params = array(), $append = false) 477 { 478 if ($append && is_array($this->_countQueryParams)) { 479 $this->_countQueryParams = array_merge($this->_countQueryParams, $params); 480 } else { 481 $this->_countQueryParams = $params; 482 } 483 484 $this->_setExecuted(false); 406 485 } 407 486 … … 419 498 public function execute($params = array(), $hydrationMode = Doctrine::FETCH_RECORD) 420 499 { 421 $this->_initialize($params); 500 if (!$this->getExecuted()) { 501 $this->_initialize($params); 502 } 422 503 423 504 return $this->getQuery()->execute($params, $hydrationMode); -
trunk/lib/Doctrine/Pager.php
r3529 r3538 40 40 41 41 /** 42 * @var Doctrine_Query $_countQuery Doctrine_Query object related to the counter of pager 43 */ 44 protected $_countQuery; 45 46 /** 47 * @var array $_countQueryParams Hold the params to be used by Doctrine_Query counter object of pager 48 */ 49 protected $_countQueryParams; 50 51 /** 42 52 * @var integer $_numResults Number of results found 43 53 */ … … 97 107 { 98 108 // retrieve the number of items found 99 $count = $this->get Query()->count($params);109 $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 100 110 $this->_setNumResults($count); 101 111 … … 378 388 * getQuery 379 389 * 380 * Returns the Doctrine_Query object related to the pager381 * 382 * @return Doctrine_Query Doctrine_Query object related to the pager390 * Returns the Doctrine_Query collector object related to the pager 391 * 392 * @return Doctrine_Query Doctrine_Query object related to the pager 383 393 */ 384 394 public function getQuery() … … 391 401 * _setQuery 392 402 * 393 * Defines the maximum number of itens per page394 * 395 * @param $query Accepts either a Doctrine_Query object or a string396 * (which does the Doctrine_Query class creation).403 * Defines the collector query to be used by pager 404 * 405 * @param Doctrine_Query Accepts either a Doctrine_Query object or a string 406 * (which does the Doctrine_Query class creation). 397 407 * @return void 398 408 */ … … 404 414 405 415 $this->_query = $query; 416 } 417 418 419 /** 420 * getCountQuery 421 * 422 * Returns the Doctrine_Query object that is used to make the count results to pager 423 * 424 * @return Doctrine_Query Doctrine_Query object related to the pager 425 */ 426 public function getCountQuery() 427 { 428 return ($this->_countQuery !== null) ? $this->_countQuery : $this->_query; 429 } 430 431 432 /** 433 * setCountQuery 434 * 435 * Defines the counter query to be used by pager 436 * 437 * @param Doctrine_Query Accepts either a Doctrine_Query object or a string 438 * (which does the Doctrine_Query class creation). 439 * @return void 440 */ 441 public function setCountQuery($query) 442 { 443 if (is_string($query)) { 444 $query = Doctrine_Query::create()->parseQuery($query); 445 } 446 447 $this->_countQuery = $query; 448 449 $this->_setExecuted(false); 450 } 451 452 453 /** 454 * getCountQueryParams 455 * 456 * Returns the params to be used by counter Doctrine_Query 457 * 458 * @return array Doctrine_Query counter params 459 */ 460 public function getCountQueryParams($defaultParams = array()) 461 { 462 return ($this->_countQueryParams !== null) ? $this->_countQueryParams : $defaultParams; 463 } 464 465 466 /** 467 * setCountQueryParams 468 * 469 * Defines the params to be used by counter Doctrine_Query 470 * 471 * @param array Optional params to be used by counter Doctrine_Query. 472 * If not defined, the params passed to execute method will be used. 473 * @param boolean Optional argument that append the query param instead of overriding the existent ones. 474 * @return void 475 */ 476 public function setCountQueryParams($params = array(), $append = false) 477 { 478 if ($append && is_array($this->_countQueryParams)) { 479 $this->_countQueryParams = array_merge($this->_countQueryParams, $params); 480 } else { 481 $this->_countQueryParams = $params; 482 } 483 484 $this->_setExecuted(false); 406 485 } 407 486 … … 419 498 public function execute($params = array(), $hydrationMode = Doctrine::FETCH_RECORD) 420 499 { 421 $this->_initialize($params); 500 if (!$this->getExecuted()) { 501 $this->_initialize($params); 502 } 422 503 423 504 return $this->getQuery()->execute($params, $hydrationMode);