CakePHP özel sorgu ile 1.3 paginate

0 Cevap php

Ben başka bir yerde önerilen olarak benim modeli özel bir sorgu için varsayılan yöntemleri binmek aşırı başardınız

function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array())

ve

function paginateCount($conditions = null, $recursive = 0, $extra = array())

Unfortunately this approach over-rides all pagination for this model, ve affects other pagination elsewhere. I found some code which may help where I could select whether I wanted the custom pagination used based on a variable e.g.

Benim modelde

var $useCustom = false;

function paginateCount($conditions = null, $recursive = 0, $extra = array())
{
if(!$this->useCustom)
    return parent::paginateCount($conditions, $recursive);

// code to hvele custom paginate count here
}

Ben bu yöntemi kullanarak bana bir hata verir bulduk,

Fatal error: Call to undefined method AppModel::paginateCount() in....

Ben yanlış ne yapıyorum? Ben aynı zamanda paginate işlevine benzer bir kod gerekir varsayıyorum? I $this->useCustom = 'true'; benim denetleyicisi yani bu değişkeni ayarlayabilirsiniz olduğunu düşünerek ben de doğru Am

0 Cevap