Commit: 40eccfdb8117f3fbd5d28887eb2208228131d0fd

Author: Joël Perras | Date: 2010-05-05 11:00:18 -0400
Updating the `count` finder type to the new database query syntax.
diff --git a/models/Paste.php b/models/Paste.php index 380f377..6593e49 100644 --- a/models/Paste.php +++ b/models/Paste.php @@ -69,15 +69,18 @@ class Paste extends \lithium\data\Model { public static function __init($options = array()) { parent::__init($options); $self = static::_instance(); + $self->_finders['count'] = function($self, $params, $chain) { - $result = Connections::get($self::meta('connection'))->get( - $self::meta('source') . '/_design/paste/_view/count' - ); + $config = Connections::get($self::meta('connection'), array('config' => true)); + $connection = Connections::get($self::meta('connection')); + $result = $connection->get($config['database'].'/_design/paste/_view/count'); + if (empty($result->total_rows)) { return 0; } return $result->total_rows; }; + Paste::applyFilter('save', function($self, $params, $chain) { $document = $params['record']; if (!$document->id) {